美文网首页第三方重要集成工具
iOS 叫友盟分享变得更简单

iOS 叫友盟分享变得更简单

作者: 贝勒老爷 | 来源:发表于2016-09-14 15:56 被阅读47次

    相信大家很多项目只能够用的都是友盟分享,那么我们就对友盟的调用进行机一部的封装,这样项目简单,方便改

    PPX_ShareManage.h
    /*
     *viewController                     你的控制器
     *shareTitle                            标题
     *shareContent                       内容
     *shareImage:(id)shareImage  必须是UIImage或者NSData
     *shareUrl                               分享出去的 url
     *
     */
    + (void)showViewController:(UIViewController *)viewController
                    shareTitle:(NSString *)shareTitle
                  shareContent:(NSString *)shareContent
                    shareImage:(id)shareImage
                      shareUrl:(NSString *)shareUrl;
    //有时候一些变态的需求微信里求分享出不一样的网址或者图片什么的
    + (void)configSinaIamge:(UIImage *)image;
    + (void)configWeChatUrl:(NSString *)url;
    
    PPX_ShareManage.m
    + (void)showViewController:(UIViewController *)viewController
                    shareTitle:(NSString *)shareTitle
                  shareContent:(NSString *)shareContent
                    shareImage:(id)shareImage
                      shareUrl:(NSString *)shareUrl
    {
        
        [UMSocialConfig hiddenNotInstallPlatforms:nil];
        
        [UMSocialData defaultData].extConfig.qqData.qqMessageType = UMSocialQQMessageTypeDefault;
        [UMSocialData defaultData].extConfig.qqData.url = shareUrl;
        
        [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;
        
        [UMSocialSnsService presentSnsIconSheetView:viewController
                                             appKey:XTY_UMKey
                                          shareText:shareContent
                                         shareImage:shareImage
                                    shareToSnsNames:@[UMShareToWechatSession,UMShareToWechatTimeline,UMShareToQQ,UMShareToSina]
                                           delegate:nil];
    }
    
    + (void)configSinaIamge:(UIImage *)image
    {
        [UMSocialData defaultData].extConfig.sinaData.shareImage = image;
    }
    
    + (void)configWeChatUrl:(NSString *)url
    {
        [UMSocialData defaultData].extConfig.wechatSessionData.url = url;
    }
    

    都是干货拒绝稀得鲁的啊..如果没看明白给我留言.下次会说更更好..你们的支持是前进的动力

    相关文章

      网友评论

        本文标题:iOS 叫友盟分享变得更简单

        本文链接:https://www.haomeiwen.com/subject/vgvvettx.html