admin 管理员组文章数量: 1086019
I have an iOS and Android app and I'm building a corresponding website. I would like that the webpage, if opened using a mobile device, opens the app or its corresponding app store page (without using Facebook app links). On the app side everything is working, including the url schema.
Does someone know how to implement this procedure, without external services, using HTML and JS?
Thanks in advance for your help.
I have an iOS and Android app and I'm building a corresponding website. I would like that the webpage, if opened using a mobile device, opens the app or its corresponding app store page (without using Facebook app links). On the app side everything is working, including the url schema.
Does someone know how to implement this procedure, without external services, using HTML and JS?
Thanks in advance for your help.
Share Improve this question edited Apr 3, 2024 at 4:15 icedwater 4,9073 gold badges38 silver badges53 bronze badges asked Jul 4, 2017 at 10:49 ppabloppablo 1541 gold badge4 silver badges16 bronze badges 7- encrypted.google./… – str Commented Jul 4, 2017 at 10:51
- 1 You should be able to look at the User Agent and see if they're ing to your site from a mobile phone. Even so, automatically redirecting to an App Store page is horrible UX (in my opinion). – James Gould Commented Jul 4, 2017 at 10:52
- Thanks for your advice @JayGould, I'll maybe not redirect the user to the appstore. I'll try out the solution you suggest. – ppablo Commented Jul 4, 2017 at 10:55
- The problem is that if I redirect the user, but he doesn't have the app, I get an error in the browser – ppablo Commented Jul 4, 2017 at 10:58
- 1 Oh I thought you meant if a user literally lands on your page you immediately reroute them to your app. If you're interacting with the app via your site and need to open it, absolutely reroute them directly. In that instance the User Agent is your best bet. – James Gould Commented Jul 4, 2017 at 11:00
2 Answers
Reset to default 5To be honest, this is kind of a pain to implement on your own. There is no easy way to handle everything without a ton of nasty edge cases, most notably the 'Cannot Open Page" error users will see if they don't have your app installed. Until iOS 9, a reasonable basic implementation was putting a JavaScript redirect like this into a dedicated redirect page on your site:
setTimeout(function() {
window.location = "https://yourdomain.";
}, 25);
// If "yourapp://" is registered, the user will see a dialog
// asking if they want to open your app. If they agree, your
// app will launch immediately and the timer won't fire.
// If not installed, you'll get an ugly "Cannot Open Page"
// dialogue and your fallback page will open when the timer expires.
window.location = "yourapp://";
Unfortunately this would still show a 'Cannot Open Page' error, but until recently it was possible to get around this in a reasonably user-friendly way by using a more nuanced version of this script. Sadly, Apple intentionally broke that with the iOS 9.2 update, so custom URL schemes are actually pretty much useless for deep linking now, unless you are certain the app is already installed on that device.
Apple is obviously trying to push the newer Universal Links standard as much as possible. Universal Links lets you use a normal http://
URL to a page on your website (the page could be a simple redirection to your desired fallback webpage without the custom URL trigger that causes the 'Cannot Open Page' error), which is intercepted by your phone and sent directly into your app if installed.
This is quite a lot to handle, so the best option might be a free service like Branch.io (full disclosure: I work with the team) to take care of all the technical aspects. You can find examples of apps using the Branch service here.
Source https://encoresky./blog/universal-links-ios-and-app-links-android-in-react-native/
To set up universal links on IOS, needs an 'apple-app-site-association' JSON file. To set up universal links on Android, needs an 'assetlinks.json' JSON file.
Both files need to be in the root of the web page, search the web for the proper content.
本文标签: javascriptCheck from app webpage whether related native app has been installedStack Overflow
版权声明:本文标题:javascript - Check from app webpage whether related native app has been installed - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744072873a2528809.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论