首页 > 编程知识 正文

友盟数据报告,友盟分享

时间:2023-05-05 17:25:59 阅读:253553 作者:3558

要在appdelegate里实现这两个方法,特别是下面的那个,如果是iOS9  一定要实现  否则不走回调。

//@implementation AppDelegate (UMeng)

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{

return  [UMSocialSnsService handleOpenURL:url];

}

-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(nonnull NSDictionary *)options{

return [UMSocialSnsService handleOpenURL:url];

}

//网页分享

- (void)shareWebPageToPlatformType:(UMSocialPlatformType)platformType url:(NSString *)url title:(NSString *)title description:(NSString *)description

{

//创建分享消息对象

UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];

NSDictionary *infoPlist = [[NSBundle mainBundle] infoDictionary];

NSString *icon = [[infoPlist valueForKeyPath:@"CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles"] lastObject];

UIImage* image = [UIImage imageNamed:icon];

//创建网页内容对象

UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:title descr:description thumImage:image];

//设置网页地址

shareObject.webpageUrl = url;

//分享消息对象设置分享内容对象

messageObject.shareObject = shareObject;

MPWeakSelf(self);

//调用分享接口

[[UMSocialManager defaultManager] shareToPlatform:platformType messageObject:messageObject currentViewController:self completion:^(id data, NSError *error) {

if (error) {

UMSocialLogInfo(@"************Share fail with error %@*********",error);

[MBProgressHUD showSuccess:@"分享失败" ToView:weakself.view];

}else{

[MBProgressHUD showSuccess:@"分享成功" ToView:weakself.view];

//

// if ([data isKindOfClass:[UMSocialShareResponse class]]) {

// UMSocialShareResponse *resp = data;

// //分享结果消息

// UMSocialLogInfo(@"response message is %@",resp.message);

// //第三方原始返回的数据

// UMSocialLogInfo(@"response originalResponse data is %@",resp.originalResponse);

//

// }else{

// UMSocialLogInfo(@"response data is %@",data);

// }

}

}];

}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。