uni_links
uni_links copied to clipboard
getInitialUri returns NULL iOS custom URL scheme
Hello guys! I have a set of custom URL schemes that are triggered with push notifications. Everything works fine with Android on all states (Open, Foreground/Background, Closed/Forced Quit). But not with iOS, which does not work when app is closed.
Everytime i close the app, force to open with a custom URL scheme, the app opens but the getInitialUri returns the uri as null, which is being called here:
main.dev
StreamSubscription uriSubscription;
@override
void initState() {
super.initState();
initPlatformState();
}
@override
void dispose() {
if (uriSubscription != null) {
uriSubscription.cancel();
}
super.dispose();
}
Future<void> initPlatformState() async {
debugPrint('com.fonixtelematics.app: initPlatformState');
// if (!mounted) return;
if (uriSubscription != null) {
uriSubscription.cancel();
}
await pushService.init();
uriSubscription = await URILinks().initStream();
await URILinks().checkInitialURI();
}
urilinks.dart
class URILinks {
Future<StreamSubscription> initStream() async {
return getUriLinksStream().listen(uriLinksHandler);
}
Future<void> checkInitialURI() async {
debugPrint('com.fonixtelematics.app: checkInitialURI');
return getInitialUri().then(uriLinksHandler).catchError((e) {
debugPrint(
'com.fonixtelematics.app: checkInitialURI ERROR ' + e.toString());
navigatorKey.currentState.pushNamed(Routes.main);
});
}
void uriLinksHandler(Uri uri) {
debugPrint('com.fonixtelematics.app: uriLinksHandler ' + uri.toString());
if (uri != null) {
debugPrint('com.fonixtelematics.app: uriLinksHandler ' + uri.host);
}
if (uri != null && uri.host != null && uri.host.isNotEmpty) {
switch (uri.host) {
case 'auth':
...
break;
case 'alert':
...
break;
default:
navigatorKey.currentState.pushNamed(Routes.main);
break;
}
} else {
throw (false);
}
}
}
Is anyone else having the same issue?
I had the same problem, did you solve it?
Hi @andrefcferreira and @humeng,
I'm facing the same issue with getInitialLink / getInitialUri methods returning null. Did you find any solution?
@avioli, @bbedward, @ened, @wkornewald, @markathomas, @MisterJimson: I allow myself to also tag you on this issue too. ;)
For the others, be aware that this issue is the same as #47 and #22.
Thanks in advance for your response
We are also facing the same issue. Please update here if you guys find any solution.
i have same problem how to solve it please
hey Guys, any news?
I was facing the same issue when tapping a Push notification resulted in cold-starting the iOS application, I fixed it here #129
@avioli hi, may I know are you still maintaining this plugin? Thanks!