美文网首页
iOS APP分享内容到Twitter

iOS APP分享内容到Twitter

作者: jionZ | 来源:发表于2019-06-12 16:29 被阅读0次

iOS APP分享内容到Twitter三句代码

花了一天时间最后三句代码搞定分享Twitter

遇到的过程

1、苹果自带的UIActivityViewController Twitter是不能分享的

2、在git上找到sdk发现停止更新了(还去试了一遍,需要授权相当没用) https://blog.twitter.com/developer/en_us/topics/tools/2018/discontinuing-support-for-twitter-kit-sdk.html

3、最后:

   NSString * encodedString = [NSString stringWithFormat:@"twitter://post?message=%@\n%@",textToShare,contentURL.absoluteString];

            encodedString = [encodedStringstringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];

            DLog(@"转码url:%@",  encodedString);

            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:encodedString]];

感谢这篇文章的作者:https://cloud.tencent.com/developer/ask/118327

相关文章

网友评论

      本文标题:iOS APP分享内容到Twitter

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