uni_links
uni_links copied to clipboard
getInitialLink() returns null when launching closed/terminated iOS app
I'm running getInitialLink() as soon as possible in main, and it's working fine when the app is in background (on both Android and iOS). But when the app is terminated by the system on iOS, the initialLink is null (of course I also start listening to linkStream after getInitialLink, but no link there either).
I've tested to add this function in Swift just to see if the URL is registered at all, and it is:
override func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { _logger.log((userActivity.webpageURL?.absoluteString ?? "NO WEBPAGE URL") as String) return true }
Generates log:
2021-10-15 12:08:30.154+0200 [AppDelegate] application(_:continue:restorationHandler:) ( "https://www.mywebpage.se/mypath" )
Is there any way to fix this?
Same here. When app is closed/ finished I get a Null check operator used on a null value
error. Any help?
Same problem here.
Any solution?
@LeTrang-64 @bergezps @alejandrogiubel @lisaerikssonw it's working fine, you just need to get the link and push the specified router right after your app is created (e.g MaterialApp) and not before.
This is what I'm doing currently using this version 0.5.1
.
Hope it helps.
@devmuaz you right. I fixit setting this on manifest <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
I am attempting to fetch the initial link after my MaterialApp is created and it's still always null for me on iOS
This is still happening. I tried adding logs to the native code and found that the issue is from here. https://github.com/flutter/flutter/issues/74024
The function didFinishLaunchingWithOptions is never executed.
@devmuaz Life saver! Can confirm this work in 2022 (0.5.1). Before you can put it before MaterialApp but now you have to put it after MaterialApp is created.