It is sometimes nice to be able to launch a browser from within your applications. Though not as elegant as the use of a UIWebView, it is much easier.
NOTE Because it is possible for an application to bind itself to a URL (like Google Maps), this technique can also be used to launch other applications on the device.
Here is a simple example of how to open safari with a specific URL:
1
2
| NSURL *url = [NSURL URLWithString:@"http://www.iphonedevelopertips.com"];
[[UIApplication sharedApplication] openURL:url]; |
Comments
12 Responses to “Launching the Browser from within an iPhone application”
Leave Comment
All Content Copyright © 2008-2012 • iOS Developer Tips, All Rights Reserved.
So can we launch the app store this way to a particular product page, for example?
Steve
[Reply]
In theory yes, though I’m not certain that Apple has published the URL scheme for that application. I’ll look into it and post back here if I can find anything. I can see how that would be useful … in particular if you wanted to promote other apps from another app.
[Reply]
How can I zoom UIWebView content like I am opening map on UIWebView then how can I zoom it?
[Reply]
hi,
can i test launching sms or calling some number using openURL in iphone simulator?
[Reply]
@aniruddha You can’t test the SMS function that I am aware of because there is no SMS client in the emulator. You will have to test on a real device.
[Reply]
@Rodney
Thanks for the comment.
[Reply]
Where do you put this and how do you call a button to launch it? Please help. Thank you!
[Reply]
So, it’s weird, but when I call that code, it launches the browser with two windows to the same site.
Any thoughts?
[Reply]
I want to program an iPhone application that would monitor in real time for the incoming text from the phone number associated with my arduino/GSM Playground. Once the text is received the next step is for the background application to simulate a button press inside the Clifford smart start application and start the vehicle. Is it possible to have this application launch the clifford smart start application and simulate a button press?
[Reply]
John Muchow Reply:
December 16th, 2010 at 10:30 pm
Jonathan, unfortunately I don’t think what you are after is supported by any published API(s).
[Reply]
this really helps me
and it is daam easy
thanks o(~_^)o
[Reply]
how to config for app call to other app?
example : [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:1-408-555-5555"]];
=>how to app working?
just only need [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:1-408-555-5555"]]; the app will be call?
please expalin for me
[Reply]