友盟分享步骤&

来源:互联网 发布:iphone连mac充电好吗 编辑:程序博客网 时间:2024/06/05 03:14

步骤一:配置LSApplicationQueriesSchems



text



2.配置url types

3.appdelegate.m中进行操作


 /* 打开调试日志 */

 [[UMSocialManagerdefaultManager] openLog:YES];

 

 /* 设置友盟appkey */

 [[UMSocialManagerdefaultManager] setUmSocialAppkey:@""];

 [[UMSocialManagerdefaultManager] setPlaform:UMSocialPlatformType_QQappKey:@""/*设置QQ平台的appID*/  appSecret:nilredirectURL:@"http://zy.b6ss.com/public/api/Home/APP"];

 [selfconfigUSharePlatforms];

    return YES;

}

-(void)configUSharePlatforms{

 

 /* 设置微信的appKey和appSecret */

 [[UMSocialManagerdefaultManager] setPlaform:UMSocialPlatformType_WechatSessionappKey:@""appSecret:@""redirectURL:@""];

 

  [[UMSocialManagerdefaultManager] setPlaform:UMSocialPlatformType_QQappKey:@""/*设置QQ平台的appID*/  appSecret:nilredirectURL:nil];


步骤4.(appdelegate中)


// 支持所有iOS系统

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation

{

 

 BOOL result = [[UMSocialManagerdefaultManager] handleOpenURL:urlsourceApplication:sourceApplication annotation:annotation];

 return result;

}


步骤五:

在需要弹出的界面设置代码:


-(void)clickbtn{

 NSLog(@"点击的是红色按钮");

 [UMSocialUIManagersetPreDefinePlatforms:@[@(UMSocialPlatformType_WechatSession),@(UMSocialPlatformType_WechatTimeLine),@(UMSocialPlatformType_QQ),@(UMSocialPlatformType_Qzone)]];

 [UMSocialUIManagershowShareMenuViewInWindowWithPlatformSelectionBlock:^(UMSocialPlatformType platformType,NSDictionary *userInfo) {

  // 根据获取的platformType确定所选平台进行下一步操作

  //创建分享消息对象

  UMSocialMessageObject *messageObject = [UMSocialMessageObjectmessageObject];

  //创建网页内容对象

  NSString* thumbURL = @"http://zy.b6ss.com/public/api/Home/APP";

  UMShareWebpageObject *shareObject = [UMShareWebpageObjectshareObjectWithTitle:@"这个周末玩点不一样的!" descr:@"来桌悦,玩桌游,交朋友。享受面对面的精彩!" thumImage:thumbURL];

  //设置网页地址

  shareObject.webpageUrl =@"http://zy.b6ss.com/public/api/Home/APP";

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

  messageObject.shareObject = shareObject;

  //调用分享接口

  [[UMSocialManagerdefaultManager] shareToPlatform:platformTypemessageObject:messageObject currentViewController:selfcompletion:^(id data,NSError *error) {

   if (error) {

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

   }else{

    if ([dataisKindOfClass:[UMSocialShareResponseclass]]) {

     UMSocialShareResponse *resp = data;

     //分享结果消息

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

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

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

    

    }else{

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

    }

   }

   

  }];

 }];

 

}



(注:qq的secrete可以不必填写)





原创粉丝点击