Open Facebook and Twitter native apps from your iOS App/Game - Plunge Interactive

Open Facebook and Twitter native apps from your iOS App/Game

Today we come with a small code snippet. Sometimes in your games or apps you need to launch your App’s Facebook or Twitters fan page. You can do this by just launching the web browser with the correct URL, but the elegant way of doing this is by just opening the native Twitter or Facebook app.

//facebook
if(![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"fb://profile/181239321918026"]])
{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.facebook.com/plungeinteractive"]];
}

//twitter
if(![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"twitter://user?screen_name=plungeint"]])
{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://twitter.com/plungeint"]];
}

 

As you can see, the code is very simple :-) The “IF” block allows us to check if the user has the native app installed or not, if he doesn’t, then we can just open the browser with the link to the Twitter or Facebook page.

 

This site uses cookies to store information on your computer. Some cookies on this site are essential, and the site won't work as expected without them. Read more about them

ACCEPT