友盟分享

  • cocoapods导入: pod 'UMengSocialCOM', "~> 5.2.1" #友盟分享
  • **注意和友盟统计相冲突类:UMMobClick,友盟统计删除这个类就OK
    **
  • 更具文档添加URLScheme和需要在info.plist里面设置
  • 但是代码部分真心没办法看,所以写一下:
// 导入的.h
// 友盟分享
#import 
#import 
#import 
#import 
#import 

// Appdelegate的调用
#pragma mark - UMShare

// 友盟分享平台
- (void)UMShare {
    
    [UMSocialData setAppKey:kUMShareAppKey];
    [UMSocialWechatHandler setWXAppId:kWeChatAppKey appSecret:kWeChatAppKey url:kUMShareUrl];
    [UMSocialQQHandler setQQWithAppId:kQQAppId appKey:kQQAppKey url:kUMShareUrl];
    [UMSocialSinaSSOHandler openNewSinaSSOWithAppKey:kSinaAppKey secret:kSinaAppSecret RedirectURL:kUMShareUrl];
}

  • 直接使用友盟的界面,注意如果自己定制界面不要把那些放在同一个数组,要出问题
  • 短信的直接用苹果原生的吧
// 分享
- (void)respondsToShareBarButtonItem {
    
    UMSocialUrlResource *urlResource = [[UMSocialUrlResource alloc] initWithSnsResourceType:UMSocialUrlResourceTypeWeb url:
                                        kUMShareUrl];
    [UMSocialData defaultData].extConfig.smsData.shareText = @"推荐下载人人带App";
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:kUMShareAppKey
                                      shareText:@"推荐下载人人带App"
                                     shareImage:nil
                                shareToSnsNames:@[UMShareToWechatSession,UMShareToWechatTimeline,UMShareToSina,UMShareToQQ,UMShareToQzone]
                                       delegate:self];
}
  • 苹果原生的短信分享

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
    //   [self dismissViewControllerAnimated:YES completion:nil];
    switch (result) {
        case MessageComposeResultSent:
            //信息传送成功
            [controller dismissViewControllerAnimated:YES completion:nil];
            [LXKHintTool showMessage:@"信息发送成功" InView:nil];
            break;
        case MessageComposeResultFailed:
            //信息传送失败
            [controller dismissViewControllerAnimated:YES completion:nil];
             [LXKHintTool showMessage:@"信息发送失败" InView:nil];
            break;
        case MessageComposeResultCancelled:
            //信息被用户取消传送
            [controller dismissViewControllerAnimated:YES completion:nil];
            break;
        default:
            break;
    }
}

//短信
-(void)showSMSPicker{
    Class messageClass = (NSClassFromString(@"MFMessageComposeViewController"));
    
    if (messageClass != nil) {
        // Check whether the current device is configured for sending SMS messages
        if ([messageClass canSendText]) {
            [self displaySMSComposerSheet];
        }
        else {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示信息"
                                                            message:@"该设备不支持短信功能"
                                                           delegate:nil
                                                  cancelButtonTitle:@"确定"
                                                  otherButtonTitles:nil, nil];
            [alert show];
        }
    }
    else {
    }
}

-(void)displaySMSComposerSheet
{
    MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
    picker.messageComposeDelegate =self;
    NSString *smsBody =[NSString stringWithFormat:@"推荐下载议库App%@",@"http://fir.im/augz"] ;
    picker.body=smsBody;
      [self presentViewController:picker animated:YES completion:nil];
}
  • 新浪微博有点歪,注意项目的bundleid和新浪微博填的bundleid是否一致,一定要一致啊,而且还要看是否被驳回了
  • 友盟文档觉得代码有点坑,居然没得那个类,还带官网的文档啊!

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