2014-11-14 37 views
0

我一直在试图让Tweetbot在用户点击表格行时打开用户帐户。但是,虽然Tweetbot打开,但它不显示用户帐户。我一直在使用Tweetbot URL Scheme page作为参考。Tweetbot URL计划不能打开用户

下面是我的代码:

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]; 
      } 

回答

3

的URL方案页Tweetbot 3 here

所有支持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) 
     } 
    }