If you are using uni_links, for android:launchMode="singleTask"
you have to use _handleIncomingLinks
to receive new intents
StreamSubscription? _sub;
void _handleIncomingLinks() {
if (!kIsWeb) {
// It will handle app links while the app is already started - be it in
// the foreground or in the background.
_sub = uriLinkStream.listen((Uri? uri) {
if (!mounted) return;
print('got uri: $uri');
}, onError: (Object err) {
if (!mounted) return;
print('got err: $err');
});
}
}
If using android:launchMode="singleTop"
you have to use _handleInitialUri
to receive new intents
bool _initialUriIsHandled = false;
Future<void> _handleInitialUri() async {
if (!_initialUriIsHandled) {
_initialUriIsHandled = true;
try {
if (!mounted) return;
final uri = await getInitialUri();
if (uri != null) {
//todo
}
} on PlatformException {
// Platform messages may fail but we ignore the exception
print('falied to get initial uri');
} on FormatException catch (err) {
if (!mounted) return;
print('malformed initial uri');
}
}
}
for more detail about methods check this sample