4

I am implementing the deeplink for iOS app, and its implemented, but the problem is when I clicked on deeplink API in iPhone, the app is opening but after the given time the app store page also gets open on the top of app.

Here what I am doing:

I have an node API for deeplink which is sending an HTML file name send.html who has some javascript code as:

send.html:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <script src="/deeplink-redirect.js"></script>
</head>

<body deeplink="iOS_DEEPLINK_URL" appstorelink="APP_STORE_LINK">

    <img src="logo.png" alt="logo" />
    <br />
    <a href="APP_STORE_LINK">Download the app</a>
</body>

</html>

deeplink-redirect.js

window.onload = function () {
    window.location.href = document.body.getAttribute('deeplink');
    setTimeout(function () {
        window.location.href = document.body.getAttribute('appstorelink');
    }, 500)
}

But what is going on: When I clicked on deeplink API in iPhone, it sends the above HTML file in safari and the app URL window.location.href = document.body.getAttribute('deeplink'); open the app but after 500ms code document.body.getAttribute('appstorelink'); gets executed and its open the app store on the top of my app.

But If I increase the timeout from 500 to 4000 then its working fine and app store is not opening. But I want very less time in timeout like 500 and when the app is not installed in the iPhone, it should redirect to given app store link. I have the correct apple-app-site-association file and correct GET API /apple-app-site-association.

Please suggest any solution. There are a lot of questions on the StackOverflow but no one is working for me.

Technologies: Nodejs, iOS, Hapijs, Javascript, Html.

Browser: Safari ( in iPhone )

Shubham Verma
  • 8,783
  • 6
  • 58
  • 79
  • I've implemented deep link many times , and I've to say I do use 5000 ms for delay 500ms is very less , as user need to perform action on popup in safari to open app if it is there,so basically you have to play with delay time, also you can try universal deep links – Shivam Gaur Aug 09 '19 at 07:00
  • Only call this code line 'window.location.href = document.body.getAttribute('appstorelink');' when Deeplink failed to detect app. Not call this in setTimeout function. – Ravi Sharma Aug 09 '19 at 07:26

0 Answers0