ios 如何做原生分享

来源:互联网 发布:淘宝 法律咨询 靠谱吗 编辑:程序博客网 时间:2024/04/30 13:11

    一、QQ分享,和QZone分享(不能不说下,腾讯的文档写的真差劲,文档居然与demo不一致,还好靠着自己的摸索搞定了

  QQ分享主要用到新闻分享

- (void)sharedByQQ{    [self checkNetData];        QQApiNewsObject *newsObj = [QQApiNewsObject                                objectWithURL:[NSURL URLWithString:_shareUrlStr]                                title:_shareTitleStr                                description:_shareTextStr                                previewImageURL:[NSURL URLWithString:_imageurlStr]];    SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:newsObj];    //将内容分享到qq    [QQApiInterface sendReq:req];}

qq空间分享主要用到定向发送的方法

#pragma mark - qq空间- (void)setupQQZoneShare{    if (!_TXaccessToken) {        _tencentOAuth = [[TencentOAuth alloc] initWithAppId:@"1102963885" andDelegate:self];        _permissions =  [NSMutableArray arrayWithObjects:@"get_user_info", @"get_simple_userinfo", @"add_t", nil];        [_tencentOAuth authorize:_permissions inSafari:NO];    }else{        [self sharedByQQZone];    }   }- (void)sharedByQQZone{    [self checkNetData];         NSMutableDictionary *data = [NSMutableDictionary dictionaryWithObjectsAndKeys:     _shareTextStr, @"description",     _imageurlStr, @"pics",     _shareTitleStr, @"title",     _shareUrlStr, @"url",     nil];          if (NO == [_tencentOAuth sendStory:data friendList:nil])     {     [self showInvalidTokenOrOpenIDMessage];     }    }


0 0