zoukankan      html  css  js  c++  java
  • 添加友盟SDK,实现新浪分享和微信朋友圈分享的关键代码

    //直接分享内容到新浪 ,不用弹出编辑界面

    [[UMSocialDataService defaultDataService] setSocialData:[UMSocialData defaultData]];

        UMSocialUrlResource *urlResource = [[UMSocialUrlResource alloc] initWithSnsResourceType:UMSocialUrlResourceTypeImage url:

                                            _detailModel.productInfo.imageUrl];

        UIImage * image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:_detailModel.productInfo.info]]];

        

        [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToSina] content:[NSString stringWithFormat:@"%@%@",_detailModel.productInfo.info,_detailModel.productInfo.shareUrl] image:image location:nil urlResource:urlResource presentedController:self completion:^(UMSocialResponseEntity *shareResponse){

            btn.enabled = YES;

            if (shareResponse.responseCode == UMSResponseCodeSuccess) {

                [[ActivityRemindView loadFromXib] showActivityViewInView:self.view withMsg:@"分享成功" inSeconds:1];

            }else{

                [[ActivityRemindView loadFromXib] showActivityViewInView:self.view withMsg:@"分享失败" inSeconds:1];

            }

        }];

     

     

        /*************** 带编辑页分享到到新浪 *************/

        

        

        [UMSocialConfig setFinishToastIsHidden:YES position:UMSocialiToastPositionTop];

        UMSocialData * socialData = [UMSocialData defaultData];

        socialData.urlResource = [[UMSocialUrlResource alloc] initWithSnsResourceType:UMSocialUrlResourceTypeImage url:

                                  _detailModel.productInfo.imageUrl];

        socialData.shareImage =  [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:_detailModel.productInfo.info]]];

        socialData.shareText = [NSString stringWithFormat:@"%@ %@ ",_detailModel.productInfo.info,_detailModel.productInfo.shareUrl];    

        __unsafe_unretained ProductDetailInfoController * productController = self;

        

        UMSocialControllerService * umSvc = [[UMSocialControllerService defaultControllerService] initWithUMSocialData:socialData];

        

        umSvc.socialUIDelegate = productController;

    //    [[UMSocialControllerService defaultControllerService] setShareText:[NSString stringWithFormat:@"%@%@",_detailModel.productInfo.info,_detailModel.productInfo.shareUrl] shareImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:_detailModel.productInfo.info]]] socialUIDelegate:productController];    

        //设置分享内容和回调对象

        [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToSina].snsClickHandler(self,[UMSocialControllerService defaultControllerService],YES);

     

     

    //分享到朋友圈

    [UMSocialConfig setFinishToastIsHidden:YES position:UMSocialiToastPositionTop];

        [UMSocialData defaultData].extConfig.wechatTimelineData.url = _detailModel.productInfo.shareUrl;

        UMSocialUrlResource * urlResource = [[UMSocialUrlResource allocinitWithSnsResourceType:UMSocialUrlResourceTypeImage url:_detailModel.productInfo.imageUrl];

        

        UIImage * image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:_detailModel.productInfo.info]]];

        

        [[UMSocialDataService defaultDataService]  postSNSWithTypes:@[UMShareToWechatTimeline] content:_detailModel.productInfo.info image:image location:nil urlResource:urlResource presentedController:self completion:^(UMSocialResponseEntity *response){

            

            if (response.responseCode == UMSResponseCodeSuccess) {

                [[ActivityRemindView loadFromXibshowActivityViewInView:self.view withMsg:@"分享成功" inSeconds:1];

            }else{

                [[ActivityRemindView loadFromXibshowActivityViewInView:self.view withMsg:@"分享失败" inSeconds:1];

            }

        }];

  • 相关阅读:
    Find cmd
    splitFile2SmallFile
    IPC-->PIPO
    Thread and shared lock
    Python Thread related
    linux 文件系统
    linux commands
    关于 gnome3 无法显示应用程序所有界面的反馈
    Windows 网络编程
    常见端口 HTTP代码
  • 原文地址:https://www.cnblogs.com/tianlin106/p/4177331.html
Copyright © 2011-2022 走看看