微信分享 添加URL Schemes
1. TARGETS - Info - URL Types
identifier -> weixin
URL Schemes -> 应用id

2.在AppDelegate.h 引入头文件
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
<pre name="code" >#import "WXApi.h"{/** * WXSceneSession 分享到会话 * WXSceneTimeline 分享到朋友圈 * WXSceneFavorite 分享到我的收藏 */ enum WXScene _scene;}- (id)init{ if(self = [super init]){ _scene = WXSceneSession; } return self;}-(void) changeScene:(NSInteger)scene{ _scene = scene;}- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ // 其它代码 // 向微信注册应用ID [WXApi registerApp:@"xxooxoxoxoxoxoxo"];}#pragma mark - 重写AppDelegate的handleOpenURL和openURL方法- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{ return [WXApi handleOpenURL:url delegate:self];}- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{ return [WXApi handleOpenURL:url delegate:self];} -(void) onReq:(BaseReq*)req{ if([req isKindOfClass:[GetMessageFromWXReq class]]) { // 微信请求App提供内容, 需要app提供内容后使用sendRsp返回 NSString *strTitle = [NSString stringWithFormat:@"微信请求App提供内容"]; NSString *strMsg = @"微信请求App提供内容,App要调用sendResp:GetMessageFromWXResp返回给微信"; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; alert.tag = 1000; [alert show]; [alert release]; } else if([req isKindOfClass:[ShowMessageFromWXReq class]]) { ShowMessageFromWXReq* temp = (ShowMessageFromWXReq*)req; WXMediaMessage *msg = temp.message; //显示微信传过来的内容 WXAppExtendObject *obj = msg.mediaObject; NSString *strTitle = [NSString stringWithFormat:@"微信请求App显示内容"]; NSString *strMsg = [NSString stringWithFormat:@"标题:%@ \n内容:%@ \n附带信息:%@ \n缩略图:%u bytes\n\n", msg.title, msg.description, obj.extInfo, msg.thumbData.length]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show]; [alert release]; } else if([req isKindOfClass:[LaunchFromWXReq class]]) { //从微信启动App NSString *strTitle = [NSString stringWithFormat:@"从微信启动"]; NSString *strMsg = @"这是从微信启动的消息"; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show]; [alert release]; }}-(void) onResp:(BaseResp*)resp{ if([resp isKindOfClass:[SendMessageToWXResp class]]) { NSString *strTitle = [NSString stringWithFormat:@"发送媒体消息结果"]; NSString *strMsg = [NSString stringWithFormat:@"errcode:%d", resp.errCode]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show]; [alert release]; }} 4.这是我写好的在微信会话和朋友圈分享文字或者图片的方法直接调用就可以#pragma mark - 微信, 朋友圈分享#pragma mark 文字分享- (void)sharedByWeChatWithText:(NSString *)WeChatMessage sceneType:(int)sceneType{ SendMessageToWXReq *req = [[[SendMessageToWXReq alloc] init]autorelease]; req.text = WeChatMessage; req.bText = YES; req.scene = sceneType; [WXApi sendReq:req];}#pragma mark 图片分享- (void)sharedByWeChatWithImage:(NSString *)imageName sceneType:(int)sceneType{ WXMediaMessage *message = [WXMediaMessage message]; [message setThumbImage:[UIImage imageNamed:imageName]]; WXImageObject *ext = [WXImageObject object]; NSString *filePath = [[NSBundle mainBundle] pathForResource:imageName ofType:@"png"]; ext.imageData = [NSData dataWithContentsOfFile:filePath]; UIImage *image = [UIImage imageWithData:ext.imageData]; ext.imageData = UIImagePNGRepresentation(image); message.mediaObject = ext; SendMessageToWXReq *req = [[[SendMessageToWXReq alloc] init]autorelease]; req.bText = NO; req.message = message; req.scene = sceneType; [WXApi sendReq:req];} |
微信分享 添加URL Schemes的更多相关文章
- iOS9适配 之 关于info.plist 第三方登录 添加URL Schemes白名单
近期苹果公司iOS 9系统策略更新,限制了http协议的访问,此外应用需要在“Info.plist”中将要使用的URL Schemes列为白名单,才可正常检查其他应用是否安装. 受此影响,当你的应用在 ...
- LSApplicationQueriesSchemes--关于info.plist 第三方登录 添加URL Schemes白名单
近期苹果公司iOS 9系统策略更新,限制了http协议的访问,此外应用需要在“Info.plist”中将要使用的URL Schemes列为白名单,才可正常检查其他应用是否安装. 当你的应用在iOS 9 ...
- 【转】iOS9适配 之 关于info.plist 第三方登录 添加URL Schemes白名单
近期苹果公司iOS 9系统策略更新,限制了http协议的访问,此外应用需要在“Info.plist”中将要使用的URL Schemes列为白名单,才可正常检查其他应用是否安装. 受此影响,当你的应用在 ...
- Swift URL Schemes使用
URL Schemes通常用于分享和第三方登录,但有时需要在html跳至APP,或者APP跳至另外一个APP.这时也需要使用URL Schemes. 一.html跳转至APP eg:html跳转至te ...
- WKWebView无法(通过URL schemes)跳转到其他App
Custom scheme URL 在WKWebView中默认是不支持的 (但Safari可以). 我们可以通过NSError来进行一些处理从而使得程序可以正常跳转: func webView(web ...
- iOS 之URL schemes
添加 URL schemes 步骤: 1.打开info.plist文件. 2.点击 “+ ”号添加,或者在列表上点击鼠标右键,选择 Add Row. 3.选择 URL types. 4.点击三角号展 ...
- iOS 微信打开第三方应用(Universal Links 和 URL Schemes)
一.前言 项目中时常有这种需求, 是通过链接跳转到应用内部,现在iOS主流的方案有两个 Schema: 常用在于一个应用跳转到另一个应用内部,属于应用间的跳转.当然ios9以下,网页可以通过schem ...
- 微信分享功能引入页面-控制分享时候调用的标题、图片、url和微信按钮隐藏显示控制
1.设置分享调用的标题.图片.url预览. 2.控制右上角三个点按钮的隐藏显示(和底部工具栏的显示隐藏--未测试). 3.判断网页是否在微信中被调用. <!doctype html> &l ...
- vue微信分享链接添加动态参数
微信分享时 分享链接携带参数可能不是固定的 需要在分享的前一刻才知道 这里就是动态设置分享链接的基本写法 代码不是那么详尽 但大致流程如下 1.安装引用jssdk npm install --save ...
随机推荐
- GIS软件列表
3map:行星地球项目由3map驱动,这是一个自由软件,由Telstra宽带基金会创建并支持,提供客户端与服务器的能力以在线再现虚拟地球. Amein!:其界面介于ArcMap和UMN Mapserv ...
- python中字符与ascii码转换
ASCII码转字符用chr()函数: 字符转ASCII码用ord()函数:
- Java初学之华容道游戏
package hhuarongdao; public class example { public static void main(String args[]) { new Hua_Rong_Ro ...
- .Net程序员玩转Android系列之三~快速上手(转)
转自http://www.cnblogs.com/HouZhiHouJueBlogs/p/3962122.html 快速环境搭建和Hello World 第一步:JAVA SDK(JDK)的安装: 官 ...
- JS模块式开发
问题:js文件须严格保证加载顺序(比如上例的1.js要在2.js的前面),依赖性最大的模块一定要放到最后加载,当依赖关系很复杂的时候,代码的编写和维护都会变得困难! C语言中模块开发-include ...
- Visual Studio 2012中的为创建类时的添加注释模板
我们往往需要给类添加注释,我们可以把注释块复制出来,放到文件中,然后在需要的时候,复制.粘贴.这样的重复劳动增加了程序员的体力劳动,而VS中给我们提供了项模版,我们只需要在其中修改一点点模版就能达到这 ...
- Eclipse汉化问题解决
1.删除eclipse/configuration 目录下的 org.eclipse.osgi 和org.eclipse.update 两个子目录2.重新启动 eclipse
- 一模 (2) day1
第一题: 题目大意: 设 2n 张牌分别标记为 1, 2, ..., n, n+1, ..., 2n,初始时这 2n 张牌按其标号从小到大排列.经一次洗牌后,原来的排列顺序变成 n+1, 1, n+2 ...
- IBatis.net 输出SQL语句(七)
一.IBatis.net输出SQL语句到控制台 输出IBatis.net生成的SQL语句到控制台,能够方便调试. 如果要想输出IBatis.net的SQL语句到控制台,那么只需要做如下配置即可: &l ...
- 如何在redhat下安装办公软件(openoffice)
在redhat的client版本中自带有办公软件libreoffice,而在server版的redhat中却没有自带的办公软件,那么,如何在redhat的server版下安装办公软件呢? 方法一:配置 ...