Creating App Custom URL Scheme Jul 17 2019

We can do this by adding the following fields to the info plist:

1
2
3
4
5
6
7
8
9
10
11
12
13
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
            <key>CFBundleURLName</key>
            <string>com.rderik.intoaccountapp</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>intoaccountapp</string>
            </array>
        </dict>
    </array>

Or by going to the project info and adding a new URL Type.

Create new Custom URL Scheme

The scheme is the one you’ll use to reference the app. For example, when you want to open your app form a today extension, you will use a code similar to the following:

1
2
3
4
5
    @IBAction func openAppTapped(_ sender: Any) {
        if let url = URL(string: "yourappschema://") {
            extensionContext?.open(url, completionHandler: nil)
        }
    }

Related topics/notes of interest:


** There is no comment system yet, but you can send me a message on twitter @rderik or send me an email: derik[at]rderik[dot]com.