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]];
网友评论