• 实现友盟分享


    -(void)shareWork:(id)sender{

        UIActionSheet *share = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"关闭" destructiveButtonTitle:nil otherButtonTitles:@"分享到新浪微博", @"分享给微信好友", @"分享到朋友圈",@"用短信分享", nil];

        share.actionSheetStyle = UIActionSheetStyleBlackOpaque;

        [share showInView:self.view];

    }

    //分享的代理

    #pragma mark ------UIActionSheetDelegate---------

    -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{

        if(actionSheet.cancelButtonIndex == buttonIndex){

            [actionSheet dismissWithClickedButtonIndex:buttonIndex animated:YES];

            return ;

        }

        

        NSString *urlStr = [NSString stringWithFormat:@"http://styler.shishangmao.cn/work/%@", @(self.work.id)];

        NSString *title;

        NSArray *platformTypes;

        switch (buttonIndex) {

                

            case 0://分享到新浪微博

                title = [NSString stringWithFormat:@"%@的作品%@ @时尚猫官方微博 %@",self.work.stylist.nickName, self.work.title, urlStr];

                platformTypes = @[UMShareToSina];

                [MobClick event:log_event_name_share_to_sina_weibo attributes:[NSDictionary dictionaryWithObjectsAndKeys:@(self.work.id), @"作品id", nil]];

                break;

            case 1://分享给微信好友

                title = [NSString stringWithFormat:@"%@",self.work.title];

                platformTypes = @[UMShareToWechatSession];

                [UMSocialData defaultData].extConfig.title = title;

                [UMSocialData defaultData].extConfig.wechatSessionData.url = urlStr;

                

                [MobClick event:log_event_name_share_to_wechat_session attributes:[NSDictionary dictionaryWithObjectsAndKeys:@(self.work.id), @"机构id", nil]];

                break;

            case 2://友分享到朋友圈

                [[UMSocialControllerService defaultControllerService] setShareText:self.work.title shareImage:self.shareImage socialUIDelegate:self];

                [UMSocialData defaultData].extConfig.wechatTimelineData.url = urlStr;

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

                

                [MobClick event:log_event_name_share_to_wechat attributes:[NSDictionary dictionaryWithObjectsAndKeys:@(self.work.id), @"机构id", nil]];

                break;

            case 3://用短信分享

                title = [NSString stringWithFormat:@"%@ %@", self.work.title,urlStr];

                platformTypes = @[UMShareToSms];

                

                [MobClick event:log_event_name_share_to_sms attributes:[NSDictionary dictionaryWithObjectsAndKeys:@(self.work.id), @"机构id", nil]];

                break;

            default:

                break;

        }

        if (buttonIndex <= 3) {

            [[UMSocialDataService defaultDataService] postSNSWithTypes:platformTypes content:title image:self.shareImage location:nil urlResource:nil presentedController:self completion:^(UMSocialResponseEntity *response){

                if (response.responseCode == UMSResponseCodeSuccess) {

                    [SVProgressHUD showSuccessWithStatus:@"分享成功" duration:0.5];

                    NSString *urlString = [NSString stringWithFormat:@"/works/%d/lastShareTime",self.work.id];

                    [[StylistWorkStore sharedStore] shareStylistWork:^(NSError *err) {

                        NSLog(@"========%@",err);

                    } url:urlString];

                    

                    

    //  //分享用put方式更新时间

    //                NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",[AppStatus sharedInstance].apiUrl,urlString]]

    //                                                                       cachePolicy:NSURLCacheStorageNotAllowed

    //                                                                   timeoutInterval:60.0];

    //                [request setValue:[[AppStatus sharedInstance] ua] forHTTPHeaderField:@"User-Agent"];

    //                [request setHTTPMethod:@"PUT"];

    //                NSURLResponse *response = nil;

    //

    //                NSError *error = nil;

    //                NSData* downloadedData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

    //                if (error){

    //                    NSLog(@">>%@", [error description]);

    //                }

    //                

    //                NSLog(@"======%@ ",downloadedData);

                    

                    

                }

            }];

        }

    }

  • 相关阅读:
    数据准备2 数据清洗
    数据准备1 数据导入、导出
    数据分析基本流程 Python基本数据类型 Python各种括号的使用方式
    fineBI 学习成果展示1
    未确认融资收益的计算
    合同现金流量
    公允价值持续计算的金额
    发放股票股利
    权益法未实现内部交易损益的调整
    营业外收入入不入损益
  • 原文地址:https://www.cnblogs.com/xubojoy/p/3875523.html
Copyright © 2020-2023  润新知