iOS APP分享内容到Twitter

2019-06-12  本文已影响0人  jionZ

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

上一篇 下一篇

猜你喜欢

热点阅读