iOS9.0 友盟分享详细过程

一: 申请友盟的AppKey(友盟的Key是根据应用的名称生成的!)

在友盟注册了你自己的开发者账号后就可以申请AppKey了。然后在这个方法里面设置Key

1
2
3
4
5
6
7
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
       [UMSocialData setAppKey:@"*******************"];
      //设置微信AppId、appSecret,分享url
      [UMSocialWechatHandler setWXAppId:@"*******" appSecret:@"*******" url:@"http://www.umeng.com/social"];
      //设置手机QQ 的AppId,Appkey,和分享URL,需要#import "UMSocialQQHandler.h"
      [UMSocialQQHandler setQQWithAppId:@"*******" appKey:@"*******" url:@"http://www.umeng.com/social"];
}

这里就没有再设置SSO开关,按下面的步骤写下去也是没有问题的,能满足一般的需求;

二: 下面再通过下面的步骤路径

   target---》 info -----》 URL Types  这个路径去设置自己的 URL Schemes 这里其实简单,可以看看官方的开发文档。

三:分享按钮参考代码

 

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
//***********************************************************************
//============================  友盟分享
// 这里的分享没有设置SSO开关  新浪微博 和 腾讯微博 的客户端就没有发挥相应的作用,以后可以完善!
 
    NSString * FXContentString=[NSString  stringWithFormat:@"%@%@",_storename,store_url];
    UIAlertView * ALVIew=[[UIAlertView alloc]initWithTitle:@"提示" message:@"分享成功了" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    [SGActionView showGridMenuWithTitle:@"更多分享" itemTitles:@[ @"新浪微博", @"腾讯微博", @"微信", @"朋友圈",@"QQ", @"QQ空间", @"我信朋友圈"] images:@[ [UIImage imageNamed:@"分享_09"],
 
                                                                                            [UIImage imageNamed:@"分享_11"],
 
                                                                                            [UIImage imageNamed:@"分享_15"],
 
                                                                                            [UIImage imageNamed:@"分享_05"],
 
                                                                                            [UIImage imageNamed:@"分享_07"],
 
                                                                                            [UIImage imageNamed:@"分享_13"],
 
                                                                                            [UIImage imageNamed:@"分享_03"]
 
                                                                                           ]selectedHandle:^(NSInteger index) {
 
//******************* 新浪微博分享  这里的index相当于你按钮的tag值!!!!!
if (index==1) {
// 分享店铺名称和LOGO的生成网址
[[UMSocialControllerService defaultControllerService] setShareText:FXContentString shareImage:logo.image  socialUIDelegate:self];
//设置分享内容和回调对象
[UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToSina].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);
 }
 //******************** 腾讯微博分享
else if (index==2)
{<br>[[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToTencent] content:FXContentString image:logo.image location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *shareResponse){
                      if (shareResponse.responseCode == UMSResponseCodeSuccess) {
                          [ALVIew show];
                          NSLog(@"分享成功!");
                      }
        }];
}
//******************* 微信好友分享<br>else if (index==3)
{
 
 //当分享消息类型为图文时,点击分享内容会跳转到预设的链接,设置方法如下
[UMSocialData defaultData].extConfig.wechatSessionData.url = store_url;
[UMSocialData defaultData].extConfig.wechatSessionData.title = _storename;
//使用UMShareToWechatSession,UMShareToWechatTimeline,UMShareToWechatFavorite分别代表微信好友、微信朋友圈、微信收藏
[[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToWechatSession] content:FXContentString image:logo.image location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response){
if (response.responseCode == UMSResponseCodeSuccess) {
              NSLog(@"分享成功!");
         }
       }];
}
//*************** 微信朋友圈分享
else if (index==4)
{
//当分享消息类型为图文时,点击分享内容会跳转到预设的链接,设置方法如下
[UMSocialData defaultData].extConfig.wechatTimelineData.url = store_url;
[UMSocialData defaultData].extConfig.wechatTimelineData.title = _storename;
//使用UMShareToWechatSession,UMShareToWechatTimeline,UMShareToWechatFavorite分别代表微信好友、微信朋友圈、微信收藏
[[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToWechatTimeline] content:FXContentString image:logo.image location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response){
if (response.responseCode == UMSResponseCodeSuccess) {
 
                                       NSLog(@"分享成功!");
                      }
                  }];
      }
//**************** QQ 好友分享
 else if (index==5)
{
 // QQ 分享到QQ好友设置分享内容点击的URL连接和标题
[UMSocialData defaultData].extConfig.qqData.title = _storename;
[UMSocialData defaultData].extConfig.qqData.url =store_url;
[[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToQQ] content:FXContentString image:logo.image location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response){
if (response.responseCode == UMSResponseCodeSuccess) {
    NSLog(@"分享成功!");
}
}];
}
//**************** QQ 空间分享
else if (index==6)
{
// QQ 分享到QQ空间设置分享内容点击的URL连接和标题
[UMSocialData defaultData].extConfig.qzoneData.url = store_url;
[UMSocialData defaultData].extConfig.qzoneData.title = _storename;
[[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToQzone] content:FXContentString image:logo.image location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response){
if (response.responseCode == UMSResponseCodeSuccess) {
 
                          NSLog(@"分享成功!");
                      }
                  }];
      }
 }
//=======================================================
//#############友盟分享

 

四:IOS 9.0 系统的问题

把你的info.plist 文档按文档格式打开,(选择文本编辑方式打开即可,鼠标右键)

复制粘贴下面代码

<key>LSApplicationQueriesSchemes</key> <array> <!-- 微信 URL Scheme 白名单--> <string>wechat</string> <string>weixin</string> <!-- 新浪微博 URL Scheme 白名单--> <string>sinaweibohd</string> <string>sinaweibo</string> <string>sinaweibosso</string> <string>weibosdk</string> <string>weibosdk2.5</string> <!-- QQ、Qzone URL Scheme 白名单--> <string>mqqapi</string> <string>mqq</string> <string>mqqOpensdkSSoLogin</string> <string>mqqconnect</string> <string>mqqopensdkdataline</string> <string>mqqopensdkgrouptribeshare</string> <string>mqqopensdkfriend</string> <string>mqqopensdkapi</string> <string>mqqopensdkapiV2</string> <string>mqqopensdkapiV3</string> <string>mqzoneopensdk</string> <string>wtloginmqq</string> <string>wtloginmqq2</string> <string>mqqwpa</string> <string>mqzone</string> <string>mqzonev2</string> <string>mqzoneshare</string> <string>wtloginqzone</string> <string>mqzonewx</string> <string>mqzoneopensdkapiV2</string> <string>mqzoneopensdkapi19</string> <string>mqzoneopensdkapi</string> <string>mqqbrowser</string> <string>mttbrowser</string> <!-- 人人 URL Scheme 白名单--> <string>renrenios</string> <string>renrenapi</string> <string>renren</string> <string>renreniphone</string> <!-- 来往 URL Scheme 白名单--> <string>laiwangsso</string> <!-- 易信 URL Scheme 白名单--> <string>yixin</string> <string>yixinopenapi</string> <!-- instagram URL Scheme 白名单--> <string>instagram</string> <!-- whatsapp URL Scheme 白名单--> <string>whatsapp</string> <!-- line URL Scheme 白名单--> <string>line</string> <!-- Facebook URL Scheme 白名单--> <string>fbapi</string> <string>fb-messenger-api</string> <string>fbauth2</string> <string>fbshareextension</string> </array>

 格式可以看文档  http://dev.umeng.com/social/ios/ios9

posted @   MrRisingSun  阅读(657)  评论(0编辑  收藏  举报
编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 25岁的心里话
点击右上角即可分享
微信分享提示