Local Notifications

I’m finding the documentation for this very confusing.
Refer to this:

The documentation only shows examples of how to schedule a notification but does not show examples of how to update an existing one. And also, what exactly is the difference between a “clear(id)” vs. “cancel(id)”, and a “isPresent(id)” vs “isScheduled(id)”?

Would a good example of updating or scheduling a notification be something like this?
this.localNotifications.isPresent(notifId).then(isPresent => {
alert(isPresent); // update()
}, isntPresent => {
alert(isntPresent); // schedule
});

OK, so here is a working example, for future devs:

// Check for presence of existing reminder and either update or schedule
this.localNotifications.isPresent(notifId).then(isPresent => {
//alert("isPresent: " + isPresent);
if (!isPresent){
this.localNotifications.schedule({
id: notifId,
text: 'Meeting with ’ + prospect.FirstName + " " + prospect.LastName,
at: new Date(reminderTime.toString()),
});
}
else {
this.localNotifications.update({
id: notifId,
text: 'Meeting with ’ + prospect.FirstName + " " + prospect.LastName,
at: new Date(reminderTime.toString()),
});
}
});

1 Like