友盟分享

  • 导入库 UMengSocialCOM
  • 在app启动时进行初始化

// 第三方id要自己注册
// 百度地图
#define kBaiduMapAppKey @"QBYw0OI0LwB1q3poQRQZiq4drnmOAXWq"
// 友盟
#define kUMAppKey @"57625aeae0f55a9b8f001175"
// 微信
#define kWechatAppID @"wx583a9239406dfa5f"
#define kWechatAppSecret @"d4624c36b6795d1d99dcf0547af5443d"
// QQ
#define kQQAppID @"1105476106"
#define kQQAppKey @"FtXkR3atEHANB4tG"
// 新浪微博
#define kSinaAppKey @"1576468831"
#define kSinaAppSecret @"22316f7a15b1733d8761c33f8876ba2b"


    //初始化友盟分享
    //设置友盟社会化组件appkey
    [UMSocialData setAppKey:kUMAppKey];
    //设置微信AppId、appSecret,分享url
    [UMSocialWechatHandler setWXAppId:kWechatAppID appSecret:kWechatAppSecret url:@"http://www.umeng.com/social"];
    //设置手机QQ 的AppId,Appkey,和分享URL,需要#import "UMSocialQQHandler.h"
    [UMSocialQQHandler setQQWithAppId:kQQAppID appKey:kQQAppKey url:@"http://www.umeng.com/social"];
    //打开新浪微博的SSO开关,设置新浪微博回调地址,这里必须要和你在新浪微博后台设置的回调地址一致。需要 #import "UMSocialSinaSSOHandler.h"
    [UMSocialSinaSSOHandler openNewSinaSSOWithAppKey:kSinaAppKey
                                              secret:kSinaAppSecret
                                         RedirectURL:@"http://sns.whalecloud.com/sina2/callback"];
  • 调用分享功能


- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

//使用友盟自带的view进行modal分享
    [UMSocialData defaultData].extConfig.wechatSessionData.title = @"测试";
    [UMSocialData defaultData].extConfig.wechatSessionData.url = @"http://baidu.com";
    [UMSocialSnsService presentSnsController:self appKey:kUMAppKey shareText:@"open" shareImage:[UIImage imageNamed:@"AppIcon"] shareToSnsNames:@[UMShareToWechatSession] delegate:self];
    [UMSocialData openLog:YES];
}
  • 自定义页面分享教程
  • iOS 友盟登录和分享

你可能感兴趣的:(友盟分享)