Skip to content

iOS example - initialLink #10

@iujames

Description

@iujames

Hi - first, this article and the examples here were extremely helpful to me, thank you!

I think one small detail is missing on the iOS implementation. In the platform method channel handler, when the "initialLink" method is called - it is not returning any value.

The code in question is here https://github.com/DenisovAV/deep_links_flutter/blob/master/ios/Runner/AppDelegate.swift#L23

I believe what needs to happen, to handle deep links that launch the app, is to add this line in the didFinishLaunchingWithOptions function in AppDelegate, to capture any initial link url:

let initialLink = launchOptions?[.url] as? String

Then, inside the setMethodCallHandler, as long as it passes the existing guard statement (the "initialLink" method check), return a result with this initialLink value.

methodChannel?.setMethodCallHandler({ (call: FlutterMethodCall, result: FlutterResult) in
    guard call.method == "initialLink" else {
        result(FlutterMethodNotImplemented)
        return
    }

    result(initialLink)
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions