@@ -55,7 +55,8 @@ - (id)init {
55
55
- (void )startObserving {
56
56
hasListeners = YES ;
57
57
for (NSDictionary *eventBody in pendingCoreEvents) {
58
- [self sendNotifeeCoreEvent: eventBody];
58
+ BOOL *foreground = [UIApplication sharedApplication ].applicationState == UIApplicationStateActive;
59
+ [self sendNotifeeCoreEvent: eventBody foreground: foreground];
59
60
}
60
61
[pendingCoreEvents removeAllObjects ];
61
62
}
@@ -70,26 +71,24 @@ + (BOOL)requiresMainQueueSetup {
70
71
71
72
#pragma mark - Events
72
73
73
- - (void )didReceiveNotifeeCoreEvent : (NSDictionary *_Nonnull)event {
74
+ - (void )didReceiveNotifeeCoreEvent : (NSDictionary *_Nonnull)event foreground : ( BOOL ) foreground ; {
74
75
if (hasListeners) {
75
- [self sendNotifeeCoreEvent: event];
76
+ [self sendNotifeeCoreEvent: event foreground: foreground ];
76
77
} else {
77
78
[pendingCoreEvents addObject: event];
78
79
}
79
80
}
80
81
81
- - (void )sendNotifeeCoreEvent : (NSDictionary *_Nonnull)eventBody {
82
+ - (void )sendNotifeeCoreEvent : (NSDictionary *_Nonnull)eventBody foreground : ( BOOL ) foreground ; {
82
83
dispatch_after (
83
84
dispatch_time (DISPATCH_TIME_NOW, (int64_t )(1 * NSEC_PER_SEC)), dispatch_get_main_queue (), ^{
84
- if (RCTRunningInAppExtension () ||
85
- [UIApplication sharedApplication ].applicationState == UIApplicationStateBackground) {
85
+ if (RCTRunningInAppExtension () || !foreground ) {
86
86
[self sendEventWithName: kReactNativeNotifeeNotificationBackgroundEvent body: eventBody];
87
87
} else {
88
88
[self sendEventWithName: kReactNativeNotifeeNotificationEvent body: eventBody];
89
89
}
90
90
});
91
91
}
92
-
93
92
// TODO(helenaford): look into a custom format style for React Native Method signatures
94
93
// clang-format off
95
94
0 commit comments