在Cordova中终止应用程序之前是否有调用的方法?我发现有onPause/onResume
。但只有当应用程序被放到后台时,它才能工作:cordova文档。我有服务,我只想在第一次访问页面时启动一次。但当我不断访问该页面时,该服务会启动多次。
不,在cordova应用程序被杀死之前,没有任何事件发生。但是,使用localStorage
,您想做的非常简单
//you can use the following inside document.ready() or cordova's deviceready
if (localStorage["firstTimeFlag"] == null || localStorage["firstTimeFlag"] == "")
{
alert("You are here for the first time");
//here add your service,do your thing. show start tour or splash screen or something like that
window.localStorage["firstTimeFlag"] = true;
} else {
alert("You are not here for the first time");
}