I am trying to keep a log of notifications on a users phone by writing them to local storage then displaying that variable on a page.
This works, except when returning to the start screen, where the push notification event runs again even though there is no new notification. This repeats the mesaage in to the log file. i have tried setting the data.aps.alert to null after writing it to localstorage. This does set it to null but it then gets repopulated on showing the start screen again.
var currentdate = new Date();
var storelog = " " + data.aps.alert + " at " + currentdate + "
";
if(data.aps.alert!==null){
data.aps.alert = null;
localStorage.setItem("reminders", localStorage.getItem("reminders") + storelog);
}
Can't find why this keeps happening - how do I clear the notification to stop it repeating