Handling URL Schemes

suggest change

Syntax

  1. // canOpenURL method verifies if there is any app which can handle indicated URL scheme.
  2. // Swift

UIApplication.sharedApplication().canOpenURL(_ aUrl: NSURL)

  1. // Objective-C

[[UIApplication sharedApplication] canOpenURL:(NSURL *)aUrl];

  1. // openURL method tries to open a resource located by URL. YES/true if it was opened otherwise NO/false.
  2. // Swift

UIApplication.sharedApplication().openURL(_ aUrl: NSURL)

  1. // Objective-C

[[UIApplication sharedApplication] openURL:(NSURL *)aUrl];

Parameters

Parameter | Meaning |

—— | —— | aUrl | a NSURL instance which stores a built-in or custom scheme string|

Remarks

In iOS9 and above your app must list any URL schemes it will want to query. This is done by adding LSApplicationQueriesSchemes to Info.plist


iOS has built-in support for the tel, http/https ,sms, mailto, facetime schemes. It also supports http–based URLs for Youtube, Maps and iTunes apps.

Examples of built-in URL schemes:

tel: tel://123456890 or tel:123456890

http: http://www.google.com

facetime: facetime://azimov@demo.com

mailto: mailto://azimov@demo.com

sms: sms://123456890 or sms:123456890

Youtube: https://www.youtube.com/watch?v=-eCaif2QKfA

Maps:

iTunes: https://itunes.apple.com/us/artist/randy-newman/id200900

Note: Not all special characters are supported in tel scheme (for example \* or \#). This is done because of security concerns to prevent users from unauthorized redirect of calls, so in this case Phone app won’t be opened.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Handling URL Schemes:
* Handling URL Schemes

Table Of Contents
12 UIView
15 UIColor
26 UIImage
28 CALayer
30 NSDate
40 iBeacon
49 NSTimer
74 Handling URL Schemes
79 NSURL
87 AWS SDK
96 NSData
101 Segues
104 EventKit
105 NSBundle
106 SiriKit
111 StoreKit
117 3D Touch
119 Keychain
122 Block
141 AirDrop
144 UISlider
145 Carthage
146 HealthKit
151 plist
157 MVVM
164 UIPhoenix
166 Simulator
168 NSArray
169 OpenGL
175 Core Data
179 MyLayout
180 UIFont
189 Security
200 Codable