From 7ef3f951f16dc1ee6afd55767eba09fa6877f3df Mon Sep 17 00:00:00 2001 From: Salakar Date: Tue, 18 Sep 2018 14:20:52 +0100 Subject: [PATCH] [notifications] temp fix for #1393, #1445 & #1481 - cc @ryanggrey for later review in follow up PR --- src/modules/notifications/IOSNotification.js | 24 +++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/modules/notifications/IOSNotification.js b/src/modules/notifications/IOSNotification.js index d465ba77..2375fb9d 100644 --- a/src/modules/notifications/IOSNotification.js +++ b/src/modules/notifications/IOSNotification.js @@ -56,18 +56,20 @@ export default class IOSNotification { this._threadIdentifier = data.threadIdentifier; } - const complete = (fetchResult: BackgroundFetchResultValue) => { - const { notificationId } = notification; - getLogger(notifications).debug( - `Completion handler called for notificationId=${notificationId}` - ); - getNativeModule(notifications).complete(notificationId, fetchResult); - }; + if (notifications && notifications.ios) { + const complete = (fetchResult: BackgroundFetchResultValue) => { + const { notificationId } = notification; + getLogger(notifications).debug( + `Completion handler called for notificationId=${notificationId}` + ); + getNativeModule(notifications).complete(notificationId, fetchResult); + }; - if (notifications.ios.shouldAutoComplete) { - complete(notifications.ios.backgroundFetchResult.noData); - } else { - this._complete = complete; + if (notifications.ios.shouldAutoComplete) { + complete(notifications.ios.backgroundFetchResult.noData); + } else { + this._complete = complete; + } } // Defaults