The page I want to open using twitter app:
To open twitter app I use the following code:
NSURL *urlApp = [NSURL URLWithString: [NSString stringWithFormat:@"%@", @"twitter://https://twitter.com/#!/PAGE"]];
[[UIApplication sharedApplication] openURL:urlApp];
But this code doesn't seem to work as expected, I got only twitter app launched without the page which i want to show.
The following code opens twitter page on twitter app if it is already installed, otherwise opens twitter on safari:
Don't forget to replace 'username' with your name.
@Alexey: If you just want to know how to launch twitter from your application do this:
I know its quite a late response to this question and I agree that, Murat's answer is absolutely correct. Simply add a check as follows:
I hope this helps someone. Cheers!! :)
You are looking for the following url:
Note that Twitter is not installed on all devices. You should check the result of
openURL
method. If it fails, open the page in Safari with regular url.This is the full code required in Swift. I am using Swift 4 but i believe it is the same for Swift 3.
Don't forget to add the Info keys needed to use
canOpenURL
: