Search code examples
iosswiftios13custom-scheme-url

Method 'application:openURL:options:' is not called


I'm trying to open my app from a web page using custom schemes. The app is opened but the following method is not called:

func application(_ app: UIApplication, open url: URL, options [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    // This is not called
}

My info.plist looks like the following:

    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>MyApp</string>
            </array>
            <key>CFBundleURLName</key>
            <string>url here</string>
        </dict>
    </array>

The project is created with Xcode 11.1, and I'm testing on iOS 13.


Solution

  • Implement scene(_:openURLContexts:) in your scene delegate.

    If the URL launches your app, you will get scene(_:willConnectTo:options:) instead and it’s in the options.