From 10f54e714938ba841221e802cf4417201f2ef07a Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 14 Feb 2019 10:34:44 +0100 Subject: [PATCH] MOBILE-2831 core: Fix local notifications in iOS --- src/core/emulator/providers/local-notifications.ts | 11 ++--------- src/providers/local-notifications.ts | 9 ++++++++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core/emulator/providers/local-notifications.ts b/src/core/emulator/providers/local-notifications.ts index f8e4f0f65..bcf07ca6b 100644 --- a/src/core/emulator/providers/local-notifications.ts +++ b/src/core/emulator/providers/local-notifications.ts @@ -939,6 +939,8 @@ export class LocalNotificationsMock extends LocalNotifications { /** * Schedules or updates a single or multiple notifications. + * We only support using the "at" property to trigger the notification. Other properties like "in" or "every" + * aren't supported yet. * * @param {ILocalNotification | Array} [options] Notification or notifications. * @param {string} [eventName] Name of the event: schedule or update. @@ -978,15 +980,6 @@ export class LocalNotificationsMock extends LocalNotifications { // Launch the trigger event. this.fireEvent('trigger', notification); - - if (notification.trigger.every && this.scheduled[notification.id] && - !this.scheduled[notification.id].interval) { - - const interval = this.parseInterval(notification.trigger.every); - if (interval > 0) { - this.scheduled[notification.id].interval = setInterval(trigger, interval); - } - } }; this.scheduled[notification.id].timeout = setTimeout(trigger, toTriggerTime); diff --git a/src/providers/local-notifications.ts b/src/providers/local-notifications.ts index 03b2995b7..6c6b7df7c 100644 --- a/src/providers/local-notifications.ts +++ b/src/providers/local-notifications.ts @@ -191,6 +191,10 @@ export class CoreLocalNotificationsProvider { * @return {Promise} Promise resolved when done. */ protected createDefaultChannel(): Promise { + if (!this.platform.is('android')) { + return Promise.resolve(); + } + return this.push.createChannel({ id: 'default-channel-id', description: this.translate.instant('addon.calendar.calendarreminders'), @@ -293,7 +297,8 @@ export class CoreLocalNotificationsProvider { isAvailable(): boolean { const win = window; - return this.appProvider.isDesktop() || !!(win.plugin && win.plugin.notification && win.plugin.notification.local); + return this.appProvider.isDesktop() || !!(win.cordova && win.cordova.plugins && win.cordova.plugins.notification && + win.cordova.plugins.notification.local); } /** @@ -506,6 +511,8 @@ export class CoreLocalNotificationsProvider { delete notification.sound; // Use default value. } + notification.foreground = true; + // Remove from triggered, since the notification could be in there with a different time. this.removeTriggered(notification.id); this.localNotifications.schedule(notification);