dla*_*aar 1 twitter objective-c ios
我一直试图让Tweetbot在用户点击表格行时打开用户帐户.但是,虽然Tweetbot打开,但它不会显示用户帐户.我一直在使用Tweetbot URL Scheme页面作为参考.
以下是我的代码:
if (indexPath.row == 1) {
// Removed the actual username
self.destViewURL = @"http://twitter.com/dummyusername";
self.destViewTitle = @"Twitter";
// URLs to try
NSURL *twitterURL = [NSURL URLWithString:@"twitter://user?screen_name= dummyusername"];
NSURL *tweetbotURL = [NSURL URLWithString:@"tweetbot://dummyusername/timeline"];
// Check if Tweetbot is available to open it
if ([[UIApplication sharedApplication] canOpenURL:tweetbotURL]) {
[[UIApplication sharedApplication] openURL:tweetbotURL];
}
else {
// Check if Twitter is available to open it
if ([[UIApplication sharedApplication] canOpenURL:twitterURL]) {
[[UIApplication sharedApplication] openURL:twitterURL];
}
// Otherwise open it in the web view
else {
[self performSegueWithIdentifier:@"showWebView" sender:nil];
}
Run Code Online (Sandbox Code Playgroud)
Tweetbot 3的URL方案页面在这里
所有受支持的URL都tweetbot://<screenname>以此开头,这表示您需要知道用户现有的Twitter屏幕名称以链接到配置文件.
但是,我的测试显示您可以使用相同的值直接链接到配置文件 tweetbot://<screenname>/user_profile/<profile_screenname>
斯威夫特,例如
/* Tweetbot app precedence */
if let tweetbotURL = NSURL(string: "tweetbot://dummyusername/user_profile/dummyusername") {
if UIApplication.sharedApplication().canOpenURL(tweetbotURL) {
UIApplication.sharedApplication().openURL(tweetbotURL)
return
}
}
/* Twitter app fallback */
if let twitterURL = NSURL(string: "twitter:///user?screen_name= dummyusername") {
if UIApplication.sharedApplication().canOpenURL(twitterURL) {
UIApplication.sharedApplication().openURL(twitterURL)
return
}
}
/* Safari fallback */
if let webURL = NSURL(string: "http://www.twitter.com/dummyusername") {
if UIApplication.sharedApplication().canOpenURL(webURL) {
UIApplication.sharedApplication().openURL(webURL)
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
743 次 |
| 最近记录: |