Lucas santos
Lucas santos

Reputation: 113

Flutter Problem Dynamic Link opens the app inside whatsapp

When the link is opened via whatsapp, an instance of the app is opened inside whatsapp, if the app is later opened by the launcher. 2 instances of the same app are open, one by whatsapp the other by the app itself.

Steps to reproduce Steps to reproduce the behavior:

1 - Generate the link and send it to whatsapp. 2 - Click the link on whatsapp

Expected behavior It is expected that after the click, the app will be opened outside of whatsapp

FirebaseDynamicLinks.instance.getInitialLink().then((value){
    if (value != null){
        if (value.link.queryParameters["challenge_id"] != null){
            DesafioModel desafioModel = DesafioModel();
            desafioModel.id = value.link.queryParameters["challenge_id"];
            Get.offNamed("$CHALLENGE_DETAILS_ROUTE", arguments: desafioModel);
         }
     }
 });

Upvotes: 2

Views: 1659

Answers (2)

Israr
Israr

Reputation: 314

Define the launchMode in AndroidManifest.xml file as singleTask, then there will be only one instance and it will not be in any app. Your app will open separately.

      <activity
        android:name=".MainActivity"
        android:launchMode="singleTask"

For more info, checkout this : https://developer.android.com/guide/components/activities/tasks-and-back-stack

Upvotes: 2

Lucas santos
Lucas santos

Reputation: 113

For others who need it, as Jiten Basnet noted in the comments, the solution is to add

android:launchMode="singleTask" 

inside activity in AndroidManifest.xml.

Upvotes: 3

Related Questions