友盟分享 调起分享视图
这一节,我们将实现按钮的点击,编写ViewController
#import "ViewController.h"
#import "UMSocial.h" // 友盟分享
#import "UMSocialWechatHandler.h" // 微信
#import "UMSocialSinaSSOHandler.h" // 微博
#import "UMSocialQQHandler.h" // QQ和QQ空间
@interface ViewController ()<UMSocialUIDelegate>
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (IBAction)go2Share:(UIButton *)sender
{
NSString *shareContent = @"分享标题";
NSString *shareIcon = @"my_wechat_qrcode.png";
NSString *commonContent = @"主标题";
NSString *commonURL = @"http://baidu.com";
[UMSocialSnsService presentSnsIconSheetView:self
appKey:YM_Share_App_Key
shareText:shareContent
shareImage:[UIImage imageNamed:shareIcon]
shareToSnsNames:@[UMShareToQQ,
UMShareToQzone,
UMShareToSina,
UMShareToWechatSession,
UMShareToWechatTimeline]
delegate:self];
#warning 标题
[UMSocialData defaultData].extConfig.qqData.title = commonContent; // QQ 标题
[UMSocialData defaultData].extConfig.qzoneData.title = commonContent; // QQ 空间
[UMSocialData defaultData].extConfig.wechatSessionData.title = commonContent; //微信好友
[UMSocialData defaultData].extConfig.wechatTimelineData.title = commonContent; // 微信朋友圈
#warning url
[UMSocialData defaultData].extConfig.qqData.url = commonURL; // qq url
[UMSocialData defaultData].extConfig.qzoneData.url = commonURL; // QQ空间 url
[UMSocialData defaultData].extConfig.wechatSessionData.url = commonURL; // 微信好友 url
[UMSocialData defaultData].extConfig.wechatTimelineData.url = commonURL; // 微信朋友圈 url
#warning 新浪 图文链接
[UMSocialData defaultData].extConfig.sinaData.shareText = [NSString stringWithFormat:@"%@,%@",commonContent,commonURL];
}
/** 分享回调 */
-(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response
{
//根据`responseCode`得到发送结果,如果分享成功
if(response.responseCode == UMSResponseCodeSuccess)
{
//得到分享到的微博平台名
NSLog(@"share to sns name is %@",[[response.data allKeys] objectAtIndex:0]);
}
}
@end
1.png
效果图
2.png问题:现在点击QQ、微博按钮没有效果,我将会在下一篇介绍、申请第三方帐号,设置白名单.(建议真机测试,效果更佳)
网友评论