From b67a2900eb637041e97cfd59f4fccfcd304f5afd Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 4 Sep 2018 16:16:19 +0200 Subject: [PATCH] MOBILE-2567 core: Fix local notification events --- config.xml | 2 +- src/providers/local-notifications.ts | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/config.xml b/config.xml index f35f79a3a..33e6375ec 100644 --- a/config.xml +++ b/config.xml @@ -122,7 +122,7 @@ - + diff --git a/src/providers/local-notifications.ts b/src/providers/local-notifications.ts index 4002a066d..29ea131a2 100644 --- a/src/providers/local-notifications.ts +++ b/src/providers/local-notifications.ts @@ -125,17 +125,19 @@ export class CoreLocalNotificationsProvider { this.appDB = appProvider.getDB(); this.appDB.createTablesFromSchema(this.tablesSchema); - localNotifications.on('trigger', (notification, state) => { - this.trigger(notification); - }); + platform.ready().then(() => { + localNotifications.on('trigger', (notification, state) => { + this.trigger(notification); + }); - localNotifications.on('click', (notification, state) => { - if (notification && notification.data) { - this.logger.debug('Notification clicked: ', notification.data); + localNotifications.on('click', (notification, state) => { + if (notification && notification.data) { + this.logger.debug('Notification clicked: ', notification.data); - const data = textUtils.parseJSON(notification.data); - this.notifyClick(data); - } + const data = textUtils.parseJSON(notification.data); + this.notifyClick(data); + } + }); }); eventsProvider.on(CoreEventsProvider.SITE_DELETED, (site) => {