Take the 2-minute tour ×

I placed a Facebook button in my iPhone app. I want to open the iPhone's default browser when clicking on that button and loads the Facebook login page.

How can i achieve this ?

Thanks in advance.

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

When you open iPhone's default browser, your application gets to background - possibly terminated by iOS. Is that really what you want? User has no way to get back to your app.

Couple options to consider:

  • Integrate Facebook iOS library into your application. Lots of coding, since you need to write some UI code to support the integration. On the other hand it's your application and you have some control over what is going on and how to react to user actions


  • Embed browser inside your application and "open the browser" within your app. Yet again you have some control over what's going on and what to do about it


The point is: it's YOUR application. Why would you force user to shutdown your app and start using something else without any way to get back?

Well, you know all the details and based on those you want the default browser. That's ok.

share|improve this answer
Thankx JOM. Now I understood it correctly. Thanks –  Arun Jan 6 '12 at 12:11
add comment

You should do some search before posting new question to any forum

Do this way:

NSURL *url = [NSURL URLWithString:@"http://www.facebook.com"];  
[[UIApplication sharedApplication] openURL:url];
share|improve this answer
OK. Thankx Adil. –  Arun Jan 6 '12 at 9:41
Your "some search" link points to "phonegap android home button pressed". The question is about iOS application with button to open facebook homepage on default browser. I don't see a connection? –  JOM Jan 6 '12 at 11:21
+1 - nice caught, and I fixed that.. :D thanks. –  Adil Soomro Jan 6 '12 at 11:32
add comment
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.facebook.com"]];
share|improve this answer
Thankx ankit... –  Arun Jan 6 '12 at 9:50
add comment

Your Answer


