MOBILE-2831 core: Fix local notifications in iOS

main
Dani Palou 2019-02-14 10:34:44 +01:00
parent f3e72d283a
commit 10f54e7149
2 changed files with 10 additions and 10 deletions

View File

@ -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<ILocalNotification>} [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);

View File

@ -191,6 +191,10 @@ export class CoreLocalNotificationsProvider {
* @return {Promise<any>} Promise resolved when done.
*/
protected createDefaultChannel(): Promise<any> {
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 = <any> 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);