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

不羁的心 提交于 2019-12-02 08:19:22
sommesh

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;
      }
    });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!