How to open twitter page in twitter app from my iphone app?

后端 未结 5 1804
一向
一向 2021-02-04 01:44

The page I want to open using twitter app:

https://twitter.com/#!/PAGE

To open twitter app I use the following code:



        
5条回答
  •  旧巷少年郎
    2021-02-04 02:27

    The following code opens twitter page on twitter app if it is already installed, otherwise opens twitter on safari:

    NSURL *twitterURL = [NSURL URLWithString:@"twitter://user?screen_name=username"];
    if ([[UIApplication sharedApplication] canOpenURL:twitterURL])
        [[UIApplication sharedApplication] openURL:twitterURL];
    else
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.twitter.com/username"]];
    

    Don't forget to replace 'username' with your name.

提交回复
热议问题