It's possible to give your app a custom URL scheme that enables it to be launched from a link in an email, message, webpage or push notification.
What is a custom URL scheme?
The scheme of a URL is the part before the address; http, mailto, ftp and webdav are all schemes.
You can make a new scheme and tie it's action in iOS to your app by choosing your own unique scheme and registering it in the app. It's important to understand what makes a URL scheme unique and why you need that uniqueness. There is no centralised repository of URL schemes. If two apps register the same scheme there will be undefined consequences if you try to open a URL using that scheme.
In order to differentiate your app successfully from others you need to choose a scheme that is unlikely to be used by anyone else.
One piece of information that is checked for uniqueness by the Apple App Store is your apps bundle ID. As a result it's a good choice to use for the URL scheme. Apple recommends that your bundle ID is in reverse DNS format.
That looks something like this: com.kaldorgroup.myappname
This is a valid format for URL schemes also. Check here for the exact rules around URL schemes and what characters they can contain.
How to register a custom URL scheme
Every Xcode app project has an info.plist file, this is usually named YourAppName-Info.plist. If you're app has multiple targets there may be an info.plist for each one. Ensure you follow these instructions for each of them.
- In the File Navigator on the left look for the Info.plist file, by default it's in the Supporting Files Group.
- Click on the file to open it and at the bottom of the list add a new item.
- From the list of items to add, choose URL Types
- Click on the disclosure arrow to drop down the list of contained information, you’ll see an entry for URL Identifier.
- Click the plus button in the line to add a sibling entry and choose URL Schemes. Once added click the disclosure triangle next to it.
In both the URL identifier and URL Schemes > Item 0 entries insert the bundle ID of your app.
Once completed your app will now be able to respond to correctly formatted URLs opened on a device your app is running on.