iOS

Default iOS URL Schemas

· 1 min read

The following is a list of default URL Schemas supported natively in iOS (all versions):

Objective-C

// Make a phone call
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:12125551212"]];

// Open an url using default brower Safari
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.needone.app"]]

// Send an email by calling Email app
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto:[email protected]"]];

// Send a SMS
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:0400000000"

Swift

// Make a phone call
UIApplication.shared.openURL(URL(string: "tel:12125551212")!)

// Open an url using default brower Safari
UIApplication.shared.openURL(URL(string: "http://www.needone.app")!)

// Send an email by calling Email app
UIApplication.shared.openURL(URL(string: "mailto:[email protected]")!)

// Send a SMS
UIApplication.shared.openURL(URL(string: "sms:0400000000")!)

Be careful about above method openURL which will be deprecated in iOS 10. In stead, iOS 10 provides a new method called:

- (void)openURL:(NSURL *)url 
        options:(NSDictionary<NSString *,id> *)options 
completionHandler:(void (^)(BOOL success))completion;
func open(_ url: URL, 
  options: [String : Any] = [:], 
completionHandler completion: ((Bool) -> Void)? = nil)

Reference

https://developer.apple.com/reference/uikit/uiapplication/1648685-open