1

What I am doing

I am creating a web form that is being used as a QR code to open an application installed in an android / IOS phone. When the user scans the QR code the phone shall run the web form and the web form will check if the application is installed inside the phone, if the application is installed, the web form will open the application, if not it will open the google play store/app store web page based on which OS system is being used.

My problem

Right now my problem is that I do not know what is the name/id of the application to trigger/open it, the only thing I about the app know is that it is called Rymtime inside the setting and also the home screen. The application's google play store link is at here and here for the app store.

PS. I do not own/create the application and do not have any access to modify its code.

enter image description here

What I have tried

I have tried to put its name directly into the code:

window.location = "Rymtime://";

I have also tried to put the "id" thingy found inside its google play store website "www...id=com.time2clock.wai.timeemployee"

window.location = "com.time2clock.wai.timeemployee://";

My Code

I created my code based on this stack overflow question.

Below is my code:

<body>
...
            <button name="data1" type="button" onclick="getOS()">Click</button> //I use button to test out the function
...
</body>
     
<script type="text/javascript">
         function getOS() {
             var userAgent = window.navigator.userAgent,
                 platform = window.navigator.platform,
                 windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'], //as I do not own an Iphone I use this to test out the IOS part
                 iosPlatforms = ['iPhone', 'iPad', 'iPod'],
                 os = null;
             if (iosPlatforms.indexOf(platform) !== -1) {
                 ios();
             } else if (windowsPlatforms.indexOf(platform) !== -1) {
                 ios(); //as I do not own an Iphone I use this to test out the IOS part
             } else if (/Android/.test(userAgent)) {
                 android();
             }
    }
    function ios() {
        setTimeout(function () { window.location = "https://apps.apple.com/my/app/rymtime/id1447217174"; }, 25);
        window.location = "Rymtime://"; //I do not test this part because I do not own an Iphone an I am using window to see if the code is being executed, I only check if the website above is runned
    }
         function android() {
             setTimeout(function () { window.location = "https://play.google.com/store/apps/details?id=com.time2clock.wai.timeemployee"; }, 25);
             window.location = "Rymtime://"; //The application is not executed thus it redirect to the play store page.
             }
</script>

Btw is the location of an application installed inside a phone the same as the others? Like this:

somefile\somefile\packageName

Or something like this:

Username(differ)\somefile\somefile\packageName

Thanks.

Chin
  • 97
  • 2
  • 9
  • In order to open an app through an URI, the app needs to explicitly support it. – Alexander Hoffmann Dec 12 '21 at 17:04
  • How do I know if the app supports it? I just wanted to let the phone open the app automatically if it is installed. – Chin Dec 13 '21 at 07:01
  • You can see this in the android settings if go open the app info of the app. There, go to `Open by default` and check the section `Links to open in this app`. The option might have a different name on different android versions. – Alexander Hoffmann Dec 13 '21 at 07:31
  • The ```open by default``` section says ```No defaults set``` and all the other options like ```open supported links``` and ```supported web addresses(None)``` are all disabled. I guess the app doesn't have a deep link? – Chin Dec 13 '21 at 08:17
  • This would be my assumption as well. You can check how this info looks for other apps (e.g. WhatsApp shows 4 supported links for me). – Alexander Hoffmann Dec 13 '21 at 08:45
  • Ya, I checked other applications they all have supported web addresses. Is there any alternative way to achieve the same goal? – Chin Dec 13 '21 at 10:11

1 Answers1

0

I am not sure what it is for IOS but I found out that I can just add &launch=true at the end of the URL of the application's google play store page to launch the app if it is installed.

Chin
  • 97
  • 2
  • 9