iOS集成分享--友盟

今天添加了一个简单需求集成社会分享.后来决定用友盟来做.之前自己写了个微信分享的.但是考虑到后期会有扩展,所以就没有再去创轮子了.
最权威的还是看官网的教程

文档中心
看完之后基本能够做了
我习惯先看官方给出的集成可能会遇到的问题

问题
先看问题能够在心里对可能遇到的问题大致有个数,如果出现了也能快速搞定
图片

找到的一个视图集成友盟的例子
但是感觉在autolayout下不是很好用

下面贴下自己写的部分代码

// 微信分享
- (void)ShowUMengShare{
// 客户端已经安装了微信
if([WXApi isWXAppInstalled] && [WXApi isWXAppSupportApi]){

NSString *sharetext = [NSString stringWithFormat:@"",product.name,product.prospectiveProfitRate];
NSString *sessionTitle = @"";
NSString *timelineTitle = @"";

// 设置图文分享
[UMSocialData defaultData].extConfig.wxMessageType = UMSocialWXMessageTypeWeb;

// 设置当分享消息类型为图文时,点击分享内容会跳转到预设的链接
[UMSocialData defaultData].extConfig.wechatSessionData.url = kHeCaiFuWeb;

// 设置微信好友title
[UMSocialData defaultData].extConfig.wechatSessionData.title = sessionTitle;
// 设置微信朋友圈title
[UMSocialData defaultData].extConfig.wechatTimelineData.title = timelineTitle;

[UMSocialSnsService presentSnsIconSheetView:self
                                     appKey:kUMengShareAppKey
                                  shareText:sharetext
                                 shareImage:[UIImage imageNamed:@"product_Icon"]
                            shareToSnsNames:[NSArray arrayWithObjects:UMShareToWechatSession,UMShareToWechatTimeline,nil]
                                   delegate:self];
}else{
    // 未安装微信
    UIAlertView *alterView = [[UIAlertView alloc]initWithTitle:@"请先安装微信"
                                                       message:nil
                                                      delegate:self
                                             cancelButtonTitle:@"取消"
                                             otherButtonTitles: nil];
    [alterView show];

}

}

// 微信分享成功后回调方法
-(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response
{
NSString *title = @”分享到微信”;
NSString *recallInfo = @”“;
//根据responseCode得到发送结果,如果分享成功
if(response.responseCode == UMSResponseCodeSuccess)
{
// 分享成功
recallInfo = @”成功分享到微信”;
}else{
// 分享失败
recallInfo = @”让我在想会儿!!”;
}
UIAlertView *alterView = [[UIAlertView alloc]initWithTitle:title
message:recallInfo
delegate:self
cancelButtonTitle:@”取消”
otherButtonTitles:nil];
[alterView show];

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值