ios 友盟一键分享

AllShareManage.h
/**
 *viewController   控制器
 *shareMutAry      分享几个平台
 *shareTitle       分享标题
 *shareContent     分享标题
 *shareImage       分享图片
 *shareUrl         分享url
 */
+ (void)showView:(UIViewController *)viewController
     shareMutAry:(NSMutableArray *)shareMutAry
      shareTitle:(NSString *)shareTitle
    shareContent:(NSString *)shareContent
      shareImage:(id)shareImage
        shareUrl:(NSString *)shareUrl
           finsh:(void (^)(NSString *filePath))finsh;
AllShareManage.m
#import "UMSocialControllerService.h"
#import "UMSocial.h"
+ (void)showView:(UIViewController *)viewController
     shareMutAry:(NSMutableArray *)shareMutAry
      shareTitle:(NSString *)shareTitle
    shareContent:(NSString *)shareContent
      shareImage:(id)shareImage
        shareUrl:(NSString *)shareUrl
           finsh:(void (^)(NSString *finshStr))finsh
{
    
    NSString *newUlr = [shareUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    [UMSocialData defaultData].extConfig.qqData.qqMessageType = UMSocialQQMessageTypeDefault;
    [UMSocialData defaultData].extConfig.qqData.url = newUlr;
    
    [UMSocialData defaultData].extConfig.wechatSessionData.wxMessageType = UMSocialWXMessageTypeWeb;
    [UMSocialData defaultData].extConfig.wechatSessionData.url = shareUrl;
    
    [UMSocialData defaultData].extConfig.wechatTimelineData.wxMessageType = UMSocialWXMessageTypeWeb;
    [UMSocialData defaultData].extConfig.wechatTimelineData.url = shareUrl;
    
    [UMSocialData defaultData].extConfig.sinaData.shareText = [NSString stringWithFormat:@"%@%@",shareTitle,shareUrl];
    
    [UMSocialData defaultData].extConfig.title = shareTitle;
    
    [UMSocialConfig setFinishToastIsHidden:YES  position:UMSocialiToastPositionTop];
    [UMSocialConfig hiddenStatusTip:YES];
    
    NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];  //主队列
    NSBlockOperation *operation=[NSBlockOperation blockOperationWithBlock:^{
        NSLog(@"%@",[NSThread currentThread]);
        [[UMSocialDataService defaultDataService] postSNSWithTypes:@[shareMutAry[0]] content:shareContent image:shareImage location:nil urlResource:nil presentedController:viewController completion:^(UMSocialResponseEntity * response){
            NSLog(@"%@",response);
            [shareMutAry removeObjectAtIndex:0];
            if (shareMutAry.count > 0)
            {
                [AllShareManage showView:viewController shareMutAry:shareMutAry shareTitle:shareTitle shareContent:shareContent shareImage:shareImage shareUrl:shareUrl finsh:^(NSString *finshStr) {
                }];
            }
            else
            {
                finsh(@"1");
            }
        }];
    }];
    [mainQueue addOperation:operation];
}

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