MOBILE-2795 notifications: Check is triggered on plugin
This commit is contained in:
		
							parent
							
								
									6727325d8e
								
							
						
					
					
						commit
						f4d3ab4c6c
					
				| @ -298,7 +298,7 @@ export class CoreLocalNotificationsProvider { | |||||||
|         return this.appDB.getRecord(this.TRIGGERED_TABLE, { id: notification.id }).then((stored) => { |         return this.appDB.getRecord(this.TRIGGERED_TABLE, { id: notification.id }).then((stored) => { | ||||||
|             return stored.at === notification.at.getTime() / 1000; |             return stored.at === notification.at.getTime() / 1000; | ||||||
|         }).catch(() => { |         }).catch(() => { | ||||||
|             return false; |             return this.localNotifications.isTriggered(notification.id); | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -478,22 +478,23 @@ export class CoreLocalNotificationsProvider { | |||||||
|     protected scheduleNotification(notification: CoreILocalNotification): Promise<any> { |     protected scheduleNotification(notification: CoreILocalNotification): Promise<any> { | ||||||
|         // Check if the notification has been triggered already.
 |         // Check if the notification has been triggered already.
 | ||||||
|         return this.isTriggered(notification).then((triggered) => { |         return this.isTriggered(notification).then((triggered) => { | ||||||
|             if (!triggered) { |             // Cancel the current notification in case it gets scheduled twice.
 | ||||||
|                 // Check if sound is enabled for notifications.
 |             return this.localNotifications.cancel(notification.id).finally(() => { | ||||||
|                 return this.configProvider.get(CoreConstants.SETTINGS_NOTIFICATION_SOUND, true).then((soundEnabled) => { |                 if (!triggered) { | ||||||
|                     if (!soundEnabled) { |                     // Check if sound is enabled for notifications.
 | ||||||
|                         notification.sound = null; |                     return this.configProvider.get(CoreConstants.SETTINGS_NOTIFICATION_SOUND, true).then((soundEnabled) => { | ||||||
|                     } else { |                         if (!soundEnabled) { | ||||||
|                         delete notification.sound; // Use default value.
 |                             notification.sound = null; | ||||||
|                     } |                         } else { | ||||||
|  |                             delete notification.sound; // Use default value.
 | ||||||
|  |                         } | ||||||
| 
 | 
 | ||||||
|                     // Remove from triggered, since the notification could be in there with a different time.
 |                         // Remove from triggered, since the notification could be in there with a different time.
 | ||||||
|                     this.removeTriggered(notification.id); |                         this.removeTriggered(notification.id); | ||||||
|                     this.localNotifications.cancel(notification.id).finally(() => { |  | ||||||
|                         this.localNotifications.schedule(notification); |                         this.localNotifications.schedule(notification); | ||||||
|                     }); |                     }); | ||||||
|                 }); |                 } | ||||||
|             } |             }); | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user