Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS example - initialLink #10

Open
iujames opened this issue Jul 19, 2023 · 0 comments
Open

iOS example - initialLink #10

iujames opened this issue Jul 19, 2023 · 0 comments

Comments

@iujames
Copy link

iujames commented Jul 19, 2023

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)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant