繁体   English   中英

Tweetbot URL方案未打开用户

[英]Tweetbot URL Scheme not opening user

我一直试图让Tweetbot在用户点击表行时打开用户帐户。 但是,尽管Tweetbot打开了,但没有显示用户帐户。 我一直在使用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];
            }

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM