MOBILE-2795 notifications: Check is triggered on plugin

main
Pau Ferrer Ocaña 2019-01-10 14:43:18 +01:00
parent 6727325d8e
commit f4d3ab4c6c
1 changed files with 15 additions and 14 deletions

View File

@ -298,7 +298,7 @@ export class CoreLocalNotificationsProvider {
return this.appDB.getRecord(this.TRIGGERED_TABLE, { id: notification.id }).then((stored) => {
return stored.at === notification.at.getTime() / 1000;
}).catch(() => {
return false;
return this.localNotifications.isTriggered(notification.id);
});
}
@ -478,6 +478,8 @@ export class CoreLocalNotificationsProvider {
protected scheduleNotification(notification: CoreILocalNotification): Promise<any> {
// Check if the notification has been triggered already.
return this.isTriggered(notification).then((triggered) => {
// Cancel the current notification in case it gets scheduled twice.
return this.localNotifications.cancel(notification.id).finally(() => {
if (!triggered) {
// Check if sound is enabled for notifications.
return this.configProvider.get(CoreConstants.SETTINGS_NOTIFICATION_SOUND, true).then((soundEnabled) => {
@ -489,12 +491,11 @@ export class CoreLocalNotificationsProvider {
// Remove from triggered, since the notification could be in there with a different time.
this.removeTriggered(notification.id);
this.localNotifications.cancel(notification.id).finally(() => {
this.localNotifications.schedule(notification);
});
});
}
});
});
}
/**