diff --git a/RNNotifications/RNNotifications.m b/RNNotifications/RNNotifications.m index bebbf9a556a2b2af223af3e37b5cec8dbc88d685..80bb3be71ea269098befe95bb97d910c932a9a12 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]; } }