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
In 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With