swift分享到微信
来源:互联网 发布:淘宝改评价步骤 编辑:程序博客网 时间:2024/05/22 17:19
申请微信开发平台AppId
地址:open.weixin.qq.com下载微信终端sdk文件
包括以下文件:将sdk文件导入到工程
4.微信开放平台新增了微信模块用户统计功能,便于开发者统计微信功能模块的用户使用和活跃情况。开发者需要在工程中链接上:SystemConfiguration.framework,libz.dylib,libsqlite3.0.dylib,libc++.dylib
Build Settings->All->Linking
Build Phases, 增加framework,CoreTelephony和SystemConfiguration
5.桥接头文件
方法同:http://blog.csdn.net/tujiaw/article/details/47048343
Objective-CBridgingHeader.h内容如下,CommonCrypto/CommonHMAC.h可以忽略,@import UIKit;包括这个分号不可少!
6.添加微信sdk目录,我的默认就添加了。
Build Settings -> All -> SearchPaths
7.在Xcode中,选择你的工程设置项,选中“TARGETS”一栏,在“info”标签栏的“URL type“添加“URL scheme”为你所注册的应用程序id(如下图所示)。
8.注册AppId
9.分享简单文字
10.分享文章到朋友,朋友圈以及收藏
@IBAction func onShare(sender: UIBarButtonItem) { let sheet = UIAlertController(title: "文章 ", message: "分享到微信", preferredStyle: .ActionSheet) let cancelAction = UIAlertAction(title: "取消", style: .Cancel, handler: {(action) -> Void in print("cancel share") }) let shareToFriend = UIAlertAction(title: "好朋友", style: .Destructive, handler: {(action) -> Void in self.shareToWChat(WXSceneSession) }) let shareToGroupsFriends = UIAlertAction(title: "朋友圈", style: .Destructive, handler: {(action) -> Void in self.shareToWChat(WXSceneTimeline) }) let favorite = UIAlertAction(title: "收藏", style: .Default, handler: {(action) -> Void in self.shareToWChat(WXSceneFavorite) }) sheet.addAction(cancelAction) sheet.addAction(shareToFriend) sheet.addAction(shareToGroupsFriends) sheet.addAction(favorite) self.presentViewController(sheet, animated: true, completion: {() -> Void in print("present over") }) } func shareToWChat(scene: WXScene) { let page = WXWebpageObject() page.webpageUrl = content.url let msg = WXMediaMessage() msg.mediaObject = page msg.title = (scene == WXSceneTimeline ? content.title : content.userName) msg.description = content.title switch dataType { case .GoodArticle: msg.setThumbImage(Data.sharedManager.goodArticle.imagedic[content.contentImg]) case .SearchArticle: msg.setThumbImage(Data.sharedManager.searchArticle.imagedic[content.contentImg]) default: print("data type error") } let req = SendMessageToWXReq() req.message = msg req.scene = Int32(scene.rawValue) WXApi.sendReq(req) }
调试的时候必须装有微信才行!!!
github地址
1 0
- swift分享到微信
- Swift微信分享
- Swift短信分享
- iOS swift 分享
- 分享Swift语言视频教程
- swift 笔记 Airdrop分享文件
- swift中的微信分享
- 唤起系统的分享(swift)
- Swift使用友盟分享
- Swift入门基础知识大家分享
- 分享一些Swift的干货
- Swift学习一周成果分享:笔记一
- iOS之Swift折叠效果分享
- swift 微信分享接口实现
- Swift 3 编写的图片分享应用
- 【Swift】文档分享到其他应用
- 分享一些Swift的干货(续)
- swift初体验,希望有经验的一起分享下
- TIME_WAIT、 CLOSE_WAIT
- 让你的网站和移动端支持Emoji
- ubuntu14.04 桌面菜单栏和任务栏不见了
- 使用alter tablespace create datafile恢复丢失的数据文件
- 在Windows下Boost库编译方法与测试
- swift分享到微信
- HTML5 HTTP协议推送 java版
- Nginx + Tomcat + Memcached 集群搭建
- 运营商渗透测试与挑战
- HD_1016Prime Ring Problem(dfs)
- 单机版hadoop搭建
- Android CircularFloatingActionMenu在ScrollView这样的滚动View中使用(2)
- AAARedis 缓存 + Spring 的集成示例(以非XML方式配置,多了一个缓存接口)
- java基础第六天——继承以及抽象类相关的知识