Linking.getInitialURL() is not being cleared after used for deeplink

前端 未结 2 1797
遥遥无期
遥遥无期 2021-01-21 17:27

I\'ve had this problem for like 2 weeks. I used Wix\'s Navigation for navigating around the app. I followed this tutorial for implementing the deeplink/universal link.

I

2条回答
  •  走了就别回头了
    2021-01-21 18:03

    Linking.getInitialURL() gives us the same Url when we come back to the same page again, to Overcome this we can do a simple condition of not to call the DeepLink function. Something like...

    Step 1: First init a dummyDeepLinkedUrl String .

    var dummyDeepLinkedUrl;
    

    Step 2: Check for the condition like, if deeplinkUrl is coming from Linking.getInitialURL() and deeplinkUrl is not equal to the dummyDeepLinkedUrl .

    if (url && url != dummyDeepLinkedUrl) {}
    

    Step 3: If not same call the Deeplink Function and assign the deeplinkUrl to dummyDeepLinkedUrl.

        this.navigateToRespectivePage(url);
        dummyDeepLinkedUrl = url;
    

    Finally this will look like :

    Linking.getInitialURL().then(url => {
          if (url && url != dummyDeepLinkedUrl) {
            this.navigateToRespectivePage(url);
            dummyDeepLinkedUrl = url;
          }
        });
    

提交回复
热议问题