转载:分享过程

一: 申请友盟的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(@"分享成功!");

                      }

                  }];

               }

              // 我信分享

              else if (index==7)

              {

                //  分享到我信朋友圈

                if(!_account)

                  {

                      [self.navigationController pushViewController:[LogInViewController new] animated:YES];

                      return;

                  }

                  XieshuoshuoController * controller=[[XieshuoshuoController  alloc]init];

                  controller.imageview=_showCodeImageView;

                  NSLog(@"controller.imageview.image==%@",controller.imageview.image);

                  [self.navigationController pushViewController:controller animated:YES];

              }

                  }];

    }

//=======================================================

//#############友盟分享

 四: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

别以为把它直接复制加在plist 文件最后就没事了,看清楚位置。。

原文地址:https://www.cnblogs.com/damnbird/p/4994020.html