iPhone Developer Tips Stats: Past 30 days - Pageviews: 88,424 Visitors: 61,675 Thank you everyone! Let's shoot for 100,000 by May. Pass it on...
|
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
8 Responses to “Launching the Browser from within an iPhone application”
Leave Comment
So can we launch the app store this way to a particular product page, for example?
Steve
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.
How can I zoom UIWebView content like I am opening map on UIWebView then how can I zoom it?
hi,
can i test launching sms or calling some number using openURL in iphone simulator?
@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.
@Rodney
Thanks for the comment.
Where do you put this and how do you call a button to launch it? Please help. Thank you!
So, it’s weird, but when I call that code, it launches the browser with two windows to the same site.
Any thoughts?