From 882775fb591319d1bfd1daff8c9365fbcfd47415 Mon Sep 17 00:00:00 2001 From: Artal Druk Date: Thu, 2 May 2019 16:42:13 +0300 Subject: [PATCH] fixed merge issues after revert commits --- RNNotifications/RNNotifications.m | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/RNNotifications/RNNotifications.m b/RNNotifications/RNNotifications.m index bebbf9a..80bb3be 100644 --- a/RNNotifications/RNNotifications.m +++ b/RNNotifications/RNNotifications.m @@ -271,23 +271,20 @@ RCT_EXPORT_MODULE() + (void)didReceiveLocalNotification:(UILocalNotification *)notification { - - return @[ RNNotificationsRegistered, - RNNotificationsRegistrationFailed, - RNNotificationReceivedForeground, - RNNotificationReceivedBackground, - RNNotificationOpened, - RNNotificationActionReceived, - RNPushKitRegistered, - RNNotificationActionTriggered]; - -} - --(void) checkAndSendEvent:(NSString*)name body:(id)body -{ - if(_hasListeners) - { - [self sendEventWithName:name body:body]; + UIApplicationState state = [UIApplication sharedApplication].applicationState; + + NSMutableDictionary* newUserInfo = notification.userInfo.mutableCopy; + [newUserInfo removeObjectForKey:@"__id"]; + notification.userInfo = newUserInfo; + + if (state == UIApplicationStateActive) { + [self didReceiveNotificationOnForegroundState:notification.userInfo]; + } else if (state == UIApplicationStateInactive) { + NSString* notificationId = [notification.userInfo objectForKey:@"notificationId"]; + if (notificationId) { + [self clearNotificationFromNotificationsCenter:notificationId]; + } + [self didNotificationOpen:notification.userInfo]; } } -- 2.26.2