Custom URLScheme in iOS

Joon Won Lee
2 min readJan 30, 2018

--

What and Why

In iOS, apps can communicate with only indirect way.

You can make a custom URLscheme so that apps can send information to your app using the url.

A URL scheme lets you communicate with other apps through a protocol which you define.

And you must create an URL properly and ask system to open it. To support custom URL scheme, you must declare the scheme and handle it

How to implement it

Register custom URL Schemes

  • Go into your app’s info.plist
  • Add a Row “URL types”
  • Expand the first item(“Item0”)and add a row “URL identifier”, and add the value with your app Identifier(e.g. com.company.appname)
  • add a row into the first item(“item0”) in “URL types” and call it “URL schemes” and add new item under “URL Schemes” which will be used as an protocol to communicate with other apps(e.g. “yourapp”)

Using the URL scheme

some example

myapp://targetPage?param=value&anotherparam=value

This custom url will send a message to UIApplicationDelegate, so if you want to handle the url, all you need to do is provide an implementation for it in appdelegate file

Note

URLs can only contain ASCII characters, spaces are not allowed. For characters outside the ASCII character set, they should be encoded using URL encoding. URL encoding replaces unsafe ASCII characters with a % followed by two hexadecimal digits and a space with %20

--

--