I already know how to launch an app from safari, but is it possible to check if the app is installed before launching? I'm thinking to launch the app store if the app isn't currently installed on the iPhone.
The reason the App Store isn't showing (and you're receiving the "Can't open Safari" error message is due to your screen time settings. You have to make sure iTunes Store and/or App Store purchases are "Allowed." Go to Settings -> Screen Time -> Content & Privacy Restrictions. Next, tap Allowed Apps.
Option 4: Lock Safari With Guided Access This feature can stop Safari from opening apps, too: With Guided Access enabled, you can't leave Safari until you disable Guided Access mode. Safari won't even try to open links in other apps. To set up Guided Access mode, head to Settings > Accessibility > Guided Access.
Just open Safari on iOS 13 or iPadOS 13 and tap any download link on the Internet. Now you'll see a downloads icon on the top right in Safari. Tap that downloads link and a list of recently downloaded items will appear.
It's not possible to check if app is installed from a web page. You could do it inside an other app by checking if your url scheme can be opened using UIApplication's -canOpenURL: method, but there is no javascript equivalent to this.
However, you can use the following workaround:
<script language="javascript"> function open_appstore() { window.location='http://itunes.com/'; } function try_to_open_app() { setTimeout('open_appstore()', 300); } </script> <a onClick="javascript:try_to_open_app();" href="yourappurl:">App name</a>
This code will set a timeout on the link that will call the open_appstore function if this timeout ends. Since your link is pointed at the app's custom url, Safari will try to open that link and if it can, it will open the app and stop the timer, so AppStore link will not be opened.
If the app link can't be opened, when timer runs out it will display an error popup saying it can't open the page (can't get rid of that), but it will immediately go to AppStore and dismiss that error.
iOS 9 adds a really nice feature that lets your app open a http/s url: Universal Links
In iOS 10 there is a popup saying "Open in [App Name]" when you tap the link and the app is installed. If the user does not tap on "Open" in the given timeout
, this solution will use the fallback. As 300ms is too short to tap anything, this solution always fails on iOS 10.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With