1
  • Background: I have a react native app using expo managed workflow for Android & ios. Also, I have web version of this same app which can be opened from any web browser.

  • Requirement In the web version of app, I would like to place a button on click of which user should be redirected to App store - in case app is not already installed in the device OR Installed app

  • Problem In ios, I do not find any way to find out if the app is installed in the device.

Here is what I am doing to achieve my requirement in ios:

const win: Window = window;

if (win) {
var change = false;

//Fallback function
setTimeout(() => {
if (!change) {
//redirect to apple store
win.location = 'https://apps.apple.com/app/<appID>';
}
}, 2500);

//First try to open App
win.location = <app URL>;

//handle event to check app installed or not
window.onblur = function () {
change = true;
};
window.onfocus = function(){
change = false;
}
}

This works in the case wherein user does not come back to browser once app is opened. But in case user come back to browser, the app and apple store both gets open - which I want to prevent. It should always open only app if its installed or Apple store if app is not installed.

Is there a way to check if the app is installed in device rather than depending upon setTimeout?

I have already referred to below posts but unfortunately could not get desired result https://stackoverflow.com/questions/13044805/how-can-i-check-if-an-app-is-installed-from-a-web-page-on-an-iphone#:~:text=iOS%20Safari%20has%20a%20feature,something%20special%20when%20it%20loads.

iPhone browser: Checking if iPhone app is installed from browser

Note: In Android, providing 'intent://' URL handles redirecting to app or PlayStore in case app is not install.

HSP
  • 21
  • 1
  • I found another answer to your question already posted on https://stackoverflow.com/questions/56528191/how-to-fix-deep-linking-in-ios-when-the-application-has-not-installed-in-the-dev try and see if this code solves your problem. – Allan Garcia Jun 02 '23 at 13:50

0 Answers0