iOS: Use Custom URL Schemes for Enterprise Apps

Enterprise

picture1

The URL scheme is a useful feature on iOS for an application to communicate with other applications.  One application can “bind” itself to a custom URL scheme and other applications can use the registered URL scheme to launch the application.  This custom URL scheme is also supported for Secure Work Space (SWS) apps, which means your app can launch other secured apps using registered URL schemes.  The Work Connect app on SWS and/or a suite of enterprise apps within the Secure Work Space container can communicate via custom URL schemes.

In this blog, you will learn how to invoke the Work Connect app from your enterprise apps and how to set up custom URL schemes.

Beginning with standard examples, several URL schemes are already supported by system apps on iOS. As you may know, the email compose screen can be invoked using the mailto:// scheme with several options, the Phone app can dial numbers using the tel:// or facetime:// scheme with phone numbers supplied, and the Message app can be opened for sending text messages with the sms: <phone> scheme. These standard schemes also work as HTML links as described in Apple’s iOS Developer Library.

You can invoke the Work Connect app on SWS using the following custom URL scheme, sector://. Also, the mailto://[email address] scheme will bring up the email compose page in the Work Connect app if the calling app is also available within the SWS container.

To register a custom URL scheme for your enterprise application, all you need to do is create an entry in the application’s info.plist file. For example, I’ve developed a sample enterprise app called ‘HelloEK’ and have created a custom URL scheme by adding the entry “URL types”, specifying the “URL identifier” and “URL Schemes”. The URL identifier string is the reversed domain address that should be unique and the same as your app’s bundleID, com.yourCompany.yourApp. The URL Schemes array contains strings used to invoke the app. When another app calls this URL, it targets the bundle identifier to launch the app.

picture2

You might have noticed that you can also define multiple URL schemes for an application, as URL Schemes is an array. Once saved, your application’s info.plist will have the following entries as viewed in XML. Once the app is installed within SWS, the custom URL scheme will be registered and the app can be launched just like the standard URL schemes shown above. e.g. helloek://

picture3


Calling Custom URL Scheme for Enterprise Apps

The following code snippet shows an example of using a custom URL scheme, targeting the Work Connect app.

picture4

In the case of inter-app communication, you should also consider whether to allow the calling app to run in the background or terminate after invoking the target application. If the calling app is not required to run in the background, set the “Application does not run in background” value to YES/TRUE in the info.plist settings.

You can check out the sample app, “HelloWorkConnect” on our BlackBerry Secure Work Space GitHub repository.

Lastly, as mentioned in the iOS Developer’s Secure Coding Guide, if your application allows launching via a registered URL scheme, you should implement the code to process the commands sent to the application through the URL string. The application must be prepared to handle not only those commands that it would like to receive, but also any commands that can be sent to the URL scheme.

That’s it. Hope this post was helpful!

About EunKyung

Enterprise Solutions Manager at BlackBerry, @echotown

Join the conversation

Show comments Hide comments
+ -
blog comments powered by Disqus