i was doing deep linking for my flutter app. The dependency i am using is AppLinks. Everything is working perfectly fine for iOS but for android, it is only working when the app is running in the background. If we remove the app from the background, it's not getting opened or say not working. I am seeking a solution for that.
This is my flutter code below :-
`Future<void> initDeepLinks() async {
_appLinks = AppLinks();
final appLink = await _appLinks.getInitialAppLink();
if (appLink != null) {
refresh();
openAppLink(appLink);
print('getInitialAppLink: $appLink');
}
_linkSubscription = _appLinks.uriLinkStream.listen((uri) {
print('onAppLink: $uri');
update();
openAppLink(uri);
});
}
void openAppLink(Uri uri) {
if (uri.path.contains('activeOrder')) {
onBottomNavItemPressed(3);
Get.find<OrdersController>().tabController?.index = 0;
}
if (uri.path.contains('request')) {
onBottomNavItemPressed(3);
Get.find<OrdersController>().tabController?.index = 3;
}
if (uri.path.contains('orderReview')) {
Get.to(() => OrderReviewView());
}
if (uri.path.contains('payoutHistory')) {
Get.to(() => TransactionHistory());
}
if (uri.path.contains('payoutDetails')) {
var transactionDetailsController =
Get.put(TransactionHistoryController());
// print(uri.queryParameters['transaction_id']);
transactionDetailsController.getPaymentDataDetails(
trxId: uri.queryParameters['transaction_id'] ?? "");
Get.to(() => PayoutHistoryDetailPage());
}
}
`
This is the code for the same and working fine for iOS, but it's not working for Android.
have you added the deeplink configuration to the
AndroidManifest.xml
? this is the way i'm using deeplink in my app and it works fine. first of all I use uni_links package:and for android in manifest i add the code below in activity tag:
as you see the link that opens your app should be like this, for example you are increasing your wallet and after payment the link is :
see the code below how i use to back to the app:
even if you close the app, the deeplink will open it again, and you can manage the navigation by the query of your link like what: from this link
exampleapp://example/payment?success
you can understand that it is coming to the app because of payment:and the
type
tells you to navigate to payment page from the beginning.Edit: these explanation that I've said before is completely true, and when I checked your Manifest code I saw that you have multiple configs for your deeplink.
it is not recommended to do add all the configs with all the pathPrefix in your app, if you have just one pathPrefix it will be ok to do that but please delete those lines that you've added before and please add these lines below instead:
you should use main config in your manifest and check your
pathPrefix
in your Flutter code.happy coding...