1

I am using javascript to check if app is installed or not, if my app installed i want to open my app or else it will redirect to play store account. the issue is that it is redirecting to play store even i already have app installed

This is my .html file where i am checking for app

 <!DOCTYPE html>
<html>
    <body>
        <script type="text/javascript">
            window.onload = function() {
                // Deep link to your app goes here
                document.getElementById("l").src = "intent://sdf/SplashScreen#Intent;scheme=vsd;package=com.sdf.android.ff;end";

                setTimeout(function() {
                    // Link to the App Store should go here -- only fires if deep link fails                
                    window.location = "https://play.google.com/store/apps/details?id=com.sdf.android.dffd";
                }, 500);
            };
        </script>
        <iframe id="l" width="1" height="1" style="visibility:hidden"></iframe>
    </body>
</html>
chris
  • 649
  • 3
  • 12
  • 34

1 Answers1

1

It solved by this way

<html>
<head>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script>


var fallbackToStore = function() {
  window.location.replace('https://play.google.com/store/apps/details?id=packgename');
};
var openApp = function() {
  window.location.replace('intent://app/SplashScreen#Intent;scheme=app_;package=com.sdf.android.dsds;end');
};
var triggerAppOpen = function() {
  openApp();
  setTimeout(fallbackToStore, 700);
};

triggerAppOpen();

</script>
</head>
<body>

</body>

</html>
chris
  • 649
  • 3
  • 12
  • 34
  • 2
    I tried your solution but the timeout is still executed and the apple store is still opened even after the app is launched. how did you manage this? – eugeniobac Jan 08 '20 at 20:53
  • @eugeniobac I think this solution only works for android- it wont work on ios(since you mentioned apple store). Apple broke this to implement universal links. – Nirvan Anjirbag Dec 23 '20 at 18:20