From 8f91a34c114d687fd102544e67b072e5888aa8d0 Mon Sep 17 00:00:00 2001 From: Albert Gasset Date: Fri, 7 Sep 2018 10:20:40 +0200 Subject: [PATCH] MOBILE-2567: Fix local notifications on Android 8 --- config.xml | 2 +- src/addon/calendar/providers/calendar.ts | 9 ++++++++- .../pushnotifications/providers/pushnotifications.ts | 9 ++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/config.xml b/config.xml index 33e6375ec..36612b734 100644 --- a/config.xml +++ b/config.xml @@ -122,7 +122,7 @@ - + diff --git a/src/addon/calendar/providers/calendar.ts b/src/addon/calendar/providers/calendar.ts index 29681ac8e..914726cb7 100644 --- a/src/addon/calendar/providers/calendar.ts +++ b/src/addon/calendar/providers/calendar.ts @@ -13,6 +13,7 @@ // limitations under the License. import { Injectable } from '@angular/core'; +import { TranslateService } from '@ngx-translate/core'; import { CoreLoggerProvider } from '@providers/logger'; import { CoreSitesProvider } from '@providers/sites'; import { CoreSite } from '@classes/site'; @@ -131,7 +132,8 @@ export class AddonCalendarProvider { constructor(logger: CoreLoggerProvider, private sitesProvider: CoreSitesProvider, private groupsProvider: CoreGroupsProvider, private coursesProvider: CoreCoursesProvider, private timeUtils: CoreTimeUtilsProvider, - private localNotificationsProvider: CoreLocalNotificationsProvider, private configProvider: CoreConfigProvider) { + private localNotificationsProvider: CoreLocalNotificationsProvider, private configProvider: CoreConfigProvider, + private translate: TranslateService) { this.logger = logger.getInstance('AddonCalendarProvider'); this.sitesProvider.createTablesFromSchema(this.tablesSchema); } @@ -460,6 +462,11 @@ export class AddonCalendarProvider { title: event.name, text: startDate.toLocaleString(), at: dateTriggered, + channelParams: { + channelID: 'notifications', + channelName: this.translate.instant('addon.notifications.notifications'), + importance: 4 // IMPORTANCE_HIGH + }, data: { eventid: event.id, siteid: siteId diff --git a/src/addon/pushnotifications/providers/pushnotifications.ts b/src/addon/pushnotifications/providers/pushnotifications.ts index 971e8da42..32b608c3f 100644 --- a/src/addon/pushnotifications/providers/pushnotifications.ts +++ b/src/addon/pushnotifications/providers/pushnotifications.ts @@ -13,6 +13,7 @@ // limitations under the License. import { Injectable, NgZone } from '@angular/core'; +import { TranslateService } from '@ngx-translate/core'; import { Platform } from 'ionic-angular'; import { Badge } from '@ionic-native/badge'; import { Push, PushObject, PushOptions } from '@ionic-native/push'; @@ -65,7 +66,8 @@ export class AddonPushNotificationsProvider { protected pushNotificationsDelegate: AddonPushNotificationsDelegate, protected sitesProvider: CoreSitesProvider, private badge: Badge, private localNotificationsProvider: CoreLocalNotificationsProvider, private utils: CoreUtilsProvider, private textUtils: CoreTextUtilsProvider, private push: Push, - private configProvider: CoreConfigProvider, private device: Device, private zone: NgZone) { + private configProvider: CoreConfigProvider, private device: Device, private zone: NgZone, + private translate: TranslateService) { this.logger = logger.getInstance('AddonPushNotificationsProvider'); this.appDB = appProvider.getDB(); this.appDB.createTablesFromSchema(this.tablesSchema); @@ -154,6 +156,11 @@ export class AddonPushNotificationsProvider { const localNotif = { id: 1, at: new Date(), + channelParams: { + channelID: 'notifications', + channelName: this.translate.instant('addon.notifications.notifications'), + importance: 4 // IMPORTANCE_HIGH + }, data: { notif: data.notif, site: data.site