admin管理员组文章数量:1389412
I am using cordova for my android application. I have lots of pages, and my main or homepage is the index.html. How can I check if it's the first time the user to land to the homepage from opening the app (regardless of how many times he clicked and open the app on different time). I just want to check if it is the first time he access the index.html after he opened the app since he can navigate back to homepage anytime from other pages. I'm using cordova and angularjs
I am using cordova for my android application. I have lots of pages, and my main or homepage is the index.html. How can I check if it's the first time the user to land to the homepage from opening the app (regardless of how many times he clicked and open the app on different time). I just want to check if it is the first time he access the index.html after he opened the app since he can navigate back to homepage anytime from other pages. I'm using cordova and angularjs
Share Improve this question edited Feb 2, 2015 at 17:43 user3569641 asked Feb 2, 2015 at 17:37 user3569641user3569641 9221 gold badge19 silver badges51 bronze badges 2- Well you can save his IMEI number and pare at the load event. If in your DB the IMEI doesn't exist then its the first time. – MDMalik Commented Feb 2, 2015 at 18:35
- 1 put a flag in index.html. store that flag to locastorage when he access your index.htm, next time check if that flag exist or not. if it exist then it's not the first time he access index.html else it's the first time. btw index.html is the start page for cordova. so whenever an app starts it will definetly gonna load. PS: localStore is not that persistent as pared to sqlite etc.. – locknies Commented Feb 2, 2015 at 18:52
1 Answer
Reset to default 8In the deviceready event you can make use of localStorage like this.
if(window.localStorage.getItem("loggedIn") != 1) {
// Running for the first time.
window.localStorage.setItem("loggedIn", 1);
console.log("1st time");
}
else
{
//Already run this app before.
console.log("running this for more than one time");
}
or use sqlite and store your values like this in a db and check it everytime you opens up the app.
sessionStorage Will be cleared each time you exit the app,
var keyName = window.sessionStorage.key(0); //Get key name
window.sessionStorage.setItem("key", "value"); //Set item
var value = window.sessionStorage.getItem("key");// Get item
window.sessionStorage.removeItem("key"); //Remove Item
window.sessionStorage.clear();//Clear storage
本文标签: javascriptHow to check android app first runCordovaStack Overflow
版权声明:本文标题:javascript - How to check android app first run - Cordova - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744646638a2617433.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论