javascript App 실행 & 스토어 실행하기

var callApp = { isIphone: false, isAndroid: false, scheme: '', appStoreUrl: '', init: function (who) { this.isIphone = (navigator.userAgent.match('iPhone') != null || navigator.userAgent.match('iPad') != null); this.isAndroid = (navigator.userAgent.match('Android') != null); if (this.isAndroid) { this.scheme = 'intent://check_install/#Intent;scheme=mbabo;package=패키지주소;end'; } else if (this.isIphone) { this.appStoreUrl = '앱스토어 주소'; } }, getIframe: function (id, url) { var iframe = document.getElementById(id); if (iframe !== null) { iframe.parentNode.removeChild(iframe); } iframe = document.createElement('iframe'); iframe.id = id; iframe.style.visibility = 'hidden'; iframe.style.display = 'none'; iframe.src = url; return iframe; }, exec: function (who, url) { this.init(who); if (this.isAndroid) { /* 안드로이드 */ location.href = this.scheme; } else if (this.isIphone) { /* IOS */ setTimeout( function() { location.href = callApp.appStoreUrl; //앱스토어 실행 }, 1000); location.href = "app_scheme://고유번호?"; } else { /* 그 외 단말기 */ location.href = url; } } }


댓글(0)