function isBrwsMobile(){ // 모바일 여부€ var isMobile = false; var tempUser = navigator.userAgent; // console.log("tempUser === " + tempUser); if( tempUser.indexOf("iPhone") > 0 || tempUser.indexOf("iPad") > 0 || tempUser.indexOf("iPot") > 0 || tempUser.indexOf("Android") > 0){ isMobile = true; } return isMobile; }; function getMobileName(){ // 모바일 os 종류˜ var mNm = ""; var tempUser = navigator.userAgent; if( tempUser.indexOf("iPhone") > 0 || tempUser.indexOf("iPad") > 0 || tempUser.indexOf("iPot") > 0 ){ mNm = "nps_i"; }else if( tempUser.indexOf("Android") > 0 || tempUser.indexOf("android") > 0 ){ mNm = "nps_a"; }else{ mNm = "etc"; } return mNm; } function getBrwsNm(){ // 브라우저 명… var agt = navigator.userAgent.toLowerCase(); if( agt.indexOf('chrome') != -1 ){ return "chrome"; }else if( agt.indexOf('opera') != -1 ){ return "opera"; }else if( agt.indexOf('firefox') != -1 ){ return "firefox"; }else if( agt.indexOf('safari') != -1 ){ return "safari"; }else if( agt.indexOf('skipstone') != -1 ){ return "skipstone"; }else if( agt.indexOf('msie') != -1 ){ return "ie10"; }else if( agt.indexOf('trident') != -1 ){ return "ie11"; }else if( agt.indexOf('netscape') != -1 ){ return "netscape"; }else{ return "etc" } }; function appLaunch(){ var mobileNm = getMobileName(); var sBrwsNm = getBrwsNm(); // var landingPage = "main.do"; // 공단요구사항에 따라 달라질 수 있음 var landingPage = ""; var schemaLandingUrlForIos = "smartnps://"; var schemaLandingUrlForAos = "Intent://external#Intent;scheme=smartnps;package=kr.or.nps.smart;end"; if( landingPage != null && landingPage != undefined && landingPage.replace(/\s/gi,"") != "" ){ schemaLandingUrlForIos = "smartnps://external?page_url=" + landingPage; schemaLandingUrlForAos = "Intent://external?page_url="+landingPage + "#Intent;scheme=smartnps;package=kr.or.nps.smart;end"; } // var userAgent = navogator.userAgent; var vistedAt = (new Date()).getTime(); // 방문 시간„ if( isBrwsMobile() ){ // 모바일의 경우 if( "nps_i" == mobileNm ){ // 아이폰의 브라우저 // console.log("++appLunch() 아이폰"); setTimeout(function(){ if( (new Date).getTime() - vistedAt < 2000 ){ top.location.href="https://itunes.apple.com/kr/app//id1321282064?mt=8"; } },500); // 마켓 실행–‰ setTimeout(function(){ location.href=schemaLandingUrlForIos; },0); // app 실행–‰ }else if( "nps_a" == mobileNm ){ // 안드로이드폰의 브라우저€ // console.log("++appLunch Android"); if( "chrome" == sBrwsNm ){ // 크롬 // 안드로이드의 크롬에서는 intent만 동작하기 때문에 intent 로 호출 해야함 setTimeout(function(){ top.location.href = schemaLandingUrlForAos; // top.location.href="market://details?id=kr.or.nps.smart"; },1000); }else{ // etc. 브라우저 -- 안드로이드 device setTimeout(function(){ if( (new Date).getTime() - vistedAt < 2000 ){ top.location.href="market://details?id=kr.or.nps.smart"; } },500); var iframe = document.createElement("iframe"); iframe.style.visibility = "hidden"; iframe.src = schemaLandingUrlForIos; // 뭐가 맞는지 확인이 안됨 // iframe.src = schemaLandingUrlForAos; // 뭐가 맞는지 확인이 안됨 document.body.appendChild(iframe); document.body.removeChild(iframe); // back 호출시 캐싱될 수 있으므로 제거 } }else{ // ios, android , 아닌 다른 os..? console.log("unknown Browser€"); location.href="https://play.google.com/store/apps/details?id=kr.or.nps.smart"; } }else{ // 모바일이 아닌경우 -- PC 접근 console.log("일반 PC 브라우저€"); location.href="https://play.google.com/store/apps/details?id=kr.or.nps.smart"; } } // End function -- !!