apicloud keyback 事件 退出app事件 再點一次退出app事件
阿新 • • 發佈:2019-01-07
//退出APP function exitNowApp(){ $api.setStorage('isFullScreen',0); //按兩次退出應用 api.addEventListener({ name : 'keyback' }, function(ret, err) { //全屏時 需要傳送事件 並關閉全屏 var isFullScreen = $api.getStorage('isFullScreen'); console.log("isFullScreen"+isFullScreen); //如果全屏 只關閉全屏 if(isFullScreen == '1'){ api.sendEvent({ name: 'clickhome', extra: {} }); }else{ api.toast({ msg : '再點一次退出應用', duration : 2000, location : 'bottom' }); api.addEventListener({ name : 'keyback' }, function(ret, err) { if($api.getStorage('isFullScreen' == "0")){ api.sendEvent({ name: 'clickhome', extra: {} }); }else{ api.closeWidget({ silent : true }); } }); } setTimeout(function() { }, 2000) }); }