首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >iOS9.0 友盟分享详细过程

iOS9.0 友盟分享详细过程

作者头像
Mr.RisingSun
发布2018-01-09 16:59:26
6370
发布2018-01-09 16:59:26
举报
文章被收录于专栏:移动端开发移动端开发

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

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

- (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 这里其实简单,可以看看官方的开发文档。

三:分享按钮参考代码

//***********************************************************************
//============================  友盟分享 
// 这里的分享没有设置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)
{[[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(@"分享成功!");
                      }
        }];
}
//******************* 微信好友分享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

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2015-11-24 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档