URL Schemes on iOS

The URL scheme is a useful little feature in iOS that allows unrelated applications to communicate with each other in a controlled way. One application can use a custom URL scheme registered by another to pass control to it, supplying arguments as required.

Standard URL Schemes

Some of the standard iOS apps have URL schemes registered and these come in useful in all kinds of apps, especially business apps. Mail can be invoked with mailto://, Phone can dial numbers using the tel:// scheme and the Messages app can be opened for sending text messages with the sms:// scheme.

These schemes work equally well from HTML links in web views or from code. The code is as simple as this:

There are standard view controllers in the MessageUI framework that give a little more control over the process of sending email and SMS text messages but these simple URLs do the job in many cases. The MessageUI framework and other aspects of iOS messaging are covered in Learning Tree’s Building iPhone® and iPad® Applications: Extended Features course.

Custom URL Schemes

Registering a custom URL scheme for your own applications is remarkably simple. All you have to do is create an entry in your application’s info.plist file. For example, consider a scheme that Learning Tree could use in a course brochure application:

Obviously the usefulness of this technique is heavily dependent on other apps knowing about the scheme so that they can make use of it. Nevertheless, custom URL schemes would be a great way of integrating a suite of apps published in a corporate environment.

Do be careful though! Opening up an application with a custom URL scheme does have some security implications. You can learn more about issues like these on Learning Tree’s new Mobile Application and Device Security course.