iOS apps without Flutter

Add Info.plist URL scheme mapping.

Info.plist example

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>appfigurate.Example</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>example</string>
        </array>
    </dict>
</array>

Call APLApplicationDidFinishLaunchingWithOptions() in your app delegate's application:didFinishLaunchingWithOptions: method.

Call APLApplicationOpenURL() in your app delegate's application:openURL:options: method.

Objective-C UIApplicationDelegate example

- (BOOL) application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    if (APLApplicationOpenURL(url) == YES) {
        return YES;
    }
    return NO;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    APLApplicationDidFinishLaunchingWithOptions(launchOptions);
    return YES;
}

Swift UIApplicationDelegate example

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
    if APLApplicationOpenURL(url) {
        return true
    }
    return false
}

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    APLApplicationDidFinishLaunchingWithOptions(launchOptions)
    return true
}

If you are using window scenes (iPadOS 13+), call APLApplicationOpenURL() in your scene delegate's scene:openURLContexts: method.

Objective-C UIWindowSceneDelegate example

- (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts API_AVAILABLE(ios(13.0)) {
    NSURL *url = [[[URLContexts allObjects] firstObject] URL];
    if (url != nil) {
        APLApplicationOpenURL(url);
    }
}

Swift UIWindowSceneDelegate example

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
    if let url = URLContexts.first?.url {
        APLApplicationOpenURL(url)
    }
}

Now jump to Info.plist options.

Last updated