2016-05-06 10 views
0

アプリがCordovaで殺される前に呼び出されるメソッドはありますか?私はonPause/onResumeがあることを知ります。しかし、アプリがバックグラウンドに置かれたときにのみ動作します:cordova doc。 私はサービスを持っています、私はページの最初の訪問で一度だけ始めたいと思います。しかし、私がそのページを訪れ続けると、そのサービスは何度も始まります。アプリを殺す前に呼び出されたメソッド - Cordova

答えて

0

いいえ、コードバスアプリが死ぬ前に発生するイベントはありません。 しかし、あなたがやりたいことは良いでしょう

//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"); 
} 
+0

localStorageを使用して非常に簡単ですが、アプリを殺害した後、私はのlocalStorage [「firstTimeFlag」]は再び代わりのlocalStorageでのsessionStorageを使用 – RadoInko

+0

nullになりたいです。 –

+0

私は試してみる、ありがとう – RadoInko

関連する問題