Ios Tweetbot URL方案未打开用户

Ios Tweetbot URL方案未打开用户,ios,objective-c,twitter,Ios,Objective C,Twitter,我一直试图让Tweetbot在用户点击表行时打开用户帐户。然而,尽管Tweetbot打开了,但它没有显示用户帐户。我一直在用这本书作为参考 下面是我的代码: if (indexPath.row == 1) { // Removed the actual username self.destViewURL = @"http://twitter.com/dummyusername"; self.destViewTitle = @"Twitter";

我一直试图让Tweetbot在用户点击表行时打开用户帐户。然而,尽管Tweetbot打开了,但它没有显示用户帐户。我一直在用这本书作为参考

下面是我的代码:

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

Tweetbot 3的URL方案页面为

所有受支持的URL都以tweetbot://开头,这意味着您需要知道用户现有的twitter屏幕名称才能链接到配置文件

但是,我的测试表明,您可以使用相同的值直接链接到配置文件tweetbot:///user_profile/

斯威夫特

   /* 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)
        }
    }

Tweetbot 3的URL方案页面为

所有受支持的URL都以tweetbot://开头,这意味着您需要知道用户现有的twitter屏幕名称才能链接到配置文件

但是,我的测试表明,您可以使用相同的值直接链接到配置文件tweetbot:///user_profile/

斯威夫特

   /* 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)
        }
    }