uni_links icon indicating copy to clipboard operation
uni_links copied to clipboard

getInitialLink() returns null when launching closed/terminated iOS app

Open lisaerikssonw opened this issue 2 years ago • 8 comments

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?

lisaerikssonw avatar Oct 15 '21 10:10 lisaerikssonw

Same here. When app is closed/ finished I get a Null check operator used on a null value error. Any help?

alejandrogiubel avatar Oct 20 '21 22:10 alejandrogiubel

Same problem here.

bergezps avatar Nov 03 '21 22:11 bergezps

Any solution?

LeTrang-64 avatar Nov 04 '21 10:11 LeTrang-64

@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 avatar Nov 17 '21 12:11 devmuaz

@devmuaz you right. I fixit setting this on manifest <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

alejandrogiubel avatar Nov 17 '21 20:11 alejandrogiubel

I am attempting to fetch the initial link after my MaterialApp is created and it's still always null for me on iOS

rpekarek-tc avatar Feb 04 '22 17:02 rpekarek-tc

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.

Neelansh-ns avatar Jul 05 '22 19:07 Neelansh-ns

@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.

DavidGXR avatar Oct 05 '22 07:10 DavidGXR