2014-11-14 35 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) 
     } 
    }