Translate

Thursday, August 22, 2013

Open Phone, SMS, Email, Map and browser apps in iPhone SDK



Here is how you can open default Phone app, SMS app, Email app, Maps app and browser app with openURL.
Open default Phone app in iPhone:
1
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://8004664411"]];
Open default SMS app in iPhone:
1
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://466453"]];
Open default Email app in iPhone:
1
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://devprograms@apple.com"]];
Open default Maps app in iPhone:
1
2
3
4
5
6
7
8
9
10
11
NSString* addressText = @"1 Infinite Loop, Cupertino, CA 95014";
 
// URL encode the spaces
 
addressText =  [addressText stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding];
 
NSString* urlText = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", addressText];
 
// lets throw this text on the log so we can view the url in the event we have an issue
 
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];
Open default Browser app in iPhone:
1
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com/"]];