Merge pull request #521 from AppFlowy-IO/app-store-redirect
feat: simplify open app or download
This commit is contained in:
commit
cdc45dcc74
|
|
@ -1,5 +1,3 @@
|
||||||
<!-- Derive from https://gist.github.com/mcxiaoke/c2dd7d24c31c5bd2d724/ -->
|
|
||||||
|
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|
@ -7,42 +5,29 @@
|
||||||
<title>AppFlowy</title>
|
<title>AppFlowy</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<script>
|
||||||
<!-- iframe used for attempting to load a custom protocol -->
|
|
||||||
<iframe style="display:none" height="0" width="0" id="loader"></iframe>
|
|
||||||
|
|
||||||
<script>(function(){
|
|
||||||
|
|
||||||
// For desktop browser, remember to pass though any metadata on the link for deep linking
|
|
||||||
var fallbackLink = 'https://appflowy.io/download/'+window.location.search+window.location.hash;
|
var fallbackLink = 'https://appflowy.io/download/'+window.location.search+window.location.hash;
|
||||||
|
|
||||||
// Simple device detection
|
|
||||||
var isiOS = navigator.userAgent.match('iPad') || navigator.userAgent.match('iPhone') || navigator.userAgent.match('iPod'),
|
|
||||||
isAndroid = navigator.userAgent.match('Android');
|
|
||||||
|
|
||||||
// Mobile
|
// Mobile
|
||||||
if (isiOS || isAndroid) {
|
const isiOS = navigator.userAgent.match('iPad') || navigator.userAgent.match('iPhone') || navigator.userAgent.match('iPod');
|
||||||
// Load our custom protocol in the iframe, for Chrome and Opera this burys the error dialog (which is actually HTML)
|
const isAndroid = navigator.userAgent.match('Android');
|
||||||
// for iOS we will get a popup error if this protocol is not supported, but it won't block javascript
|
if (isiOS) {
|
||||||
document.getElementById('loader').src = 'appflowy-flutter://'+window.location.search+window.location.hash;
|
fallbackLink = 'https://testflight.apple.com/join/6CexvkDz';
|
||||||
|
} else if (isAndroid) {
|
||||||
// The fallback link for Android needs to be https:// rather than market:// or the device will try to
|
fallbackLink = 'https://play.google.com/store/apps/details?id=io.appflowy.appflowy';
|
||||||
// load both URLs and only the last one will win. (Especially FireFox, where an "Are You Sure" dialog will appear)
|
|
||||||
// on iOS we can link directly to the App Store as our app switch will fire prior to the switch
|
|
||||||
// If you have a mobile web app, your fallback could be that instead.
|
|
||||||
fallbackLink = isAndroid ? 'https://play.google.com/store/apps/details?id=io.appflowy.appflowy' :
|
|
||||||
'https://testflight.apple.com/join/6CexvkDz' ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we just wait for everything to execute, if the user is redirected to your custom app
|
window.location = 'appflowy-flutter://'+window.location.search+window.location.hash;
|
||||||
// the timeout below will never fire, if a custom app is not present (or the user is on the Desktop)
|
|
||||||
// we will replace the current URL with the fallbackLink (store URL or desktop URL as appropriate)
|
|
||||||
window.setTimeout(function (){ window.location.replace(fallbackLink); }, 1);
|
|
||||||
|
|
||||||
})();</script>
|
function checkFocus() {
|
||||||
|
if (document.hasFocus()) {
|
||||||
|
window.location = fallbackLink;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setTimeout(checkFocus, 1000);
|
||||||
|
}
|
||||||
|
setTimeout(checkFocus, 500); // initial delay to wait for the app to open(or not)
|
||||||
|
|
||||||
<h1>Opening AppFlowy</h1>
|
</script>
|
||||||
<p>If AppFlowy does not open, you can click <a href="appflowy-flutter://">here</a> to launch the app.</p>
|
|
||||||
<p>If AppFlowy is not installed, you can <a href="https://appflowy.io/download">download AppFlowy manually</a>.</p>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue