2

I'm trying to launch my app in case it is installed and fallback to my website if tbe the app does not exist. (got some insights from : How to check if an app is installed from a web-page on an iPhone?

I was able to launch the app using custom url scheme , but was only able to so when there is user interaction (e.g. user clicks a button/link) :

 <a onclick="window.open('myapp://foo=bar', '_system')">Launch myapp</a>

However When using

window.open('myapp://foo=bar', '_system');

or

window.location = 'myapp://foo=bar'

without user interaction (e.g. on window load / document ready) the app does not launch.

Is this expected ?

Any workarounds ?

Thanks Sagi

Community
  • 1
  • 1
  • 1
    This is expected. If the user is using the browser, then they are using the browser. If you want them to use your App, just provide a button with the custom URL for them to click on. – adelphus May 15 '16 at 22:14

1 Answers1

1

Thats expected. User interaction needs to happen first before doing a call to window.open(). It can't be done programatically.

Something else you might want to look at is Universal Links. This approach to launching an app via a normal http:// link is the new preferred approach instead of using URL Schemes. With Universal Links you don't need to handle the logic to determine if the app is installed. Its handled automatically. All big companies use this approach. Check out this blog too.

johnborges
  • 2,422
  • 20
  • 33