<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>app Installed</title>
</head>
<body>
<script>
$(document).ready(function() {
const typeData = "<%= request.getAttribute("type") %>";
const $btnAndroid = $('.btn_android');
const $btnIos = $('.btn_ios');
let isOpened = false;
$btnAndroid.show();
$btnIos.show();
window.addEventListener('blur', () => {
console.log('true: its blurred')
isOpened = true;
});
window.addEventListener('pagehide', function() {
console.log('true: its pagehided')
isOpened = true;
});
document.addEventListener('visibilitychange', function() {
if (document.hidden) {
console.log('true: its visibilitychanged')
isOpened = true;
}
});
function isAppNotInstalled() {
console.log('>> isAppNotInstalled is called');
let loader = new tui.component.m.AppLoader();
if (loader.agentDetector.isAndroid()) {
console.log('>> isAndroid');
$btnAndroid.attr('href', 'intent://unione/#Intent;scheme=unione;package=com.tesco.lk.manager;end').show();
window.location.href = $btnAndroid.attr('href');
} else if (loader.agentDetector.isIOS()) {
console.log('>> isIos');
window.location.href = $btnIos.attr('href');
}
}
var appScheme;
if (typeData === 'mall') {
console.log('>> type is mall');
appScheme = 'testapp://webview?landingtype=1&webviewtype=3&url=http%3A%2F%2Fiammall.net';
} else {
console.log('>> type is else');
appScheme = 'testapp://';
}
window.location.href = appScheme;
setTimeout(() => {
if (!(document.hidden || document.webkitHidden || isOpened)) {
console.log('>> app is not installed');
isAppNotInstalled();
}
}, 2000);
});
</script>
</body>
</html>