Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open iPhone's default browser?

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

like image 800
Arun Avatar asked Jan 06 '12 09:01

Arun


People also ask

Where is default browser app in settings?

From your Home page, head to Settings. Select Apps. Tap on the three-dotted icon in the upper-right corner of the screen. Choose your default apps.

How do I make Google my default on iPhone?

Tap "Default Browser App"Tap More ( ) on your screen, then Settings. In Settings tap Default Browser > Open Chrome Settings. Tap Default Browser App and select Chrome.


1 Answers

iOS 10 has introduced new method to open a URL, see below:

Swift 3:

let url = URL(string:"http://www.booleanbites.com")! if #available(iOS 10.0, *) {     UIApplication.shared.open(url, options: [:], completionHandler: nil) } else {     // Fallback on earlier versions     UIApplication.shared.openURL(url) } 

Objective C:

NSURL *url = [NSURL URLWithString:@"http://www.booleanbites.com"];  if ([[UIApplication sharedApplication] respondsToSelector:@selector(openURL:options:completionHandler:)]) {     [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:NULL]; }else{     // Fallback on earlier versions     [[UIApplication sharedApplication] openURL:url]; } 
like image 80
Adil Soomro Avatar answered Sep 20 '22 18:09

Adil Soomro