diff --git a/ios/RCTOneSignal/RCTOneSignalEventEmitter.m b/ios/RCTOneSignal/RCTOneSignalEventEmitter.m index 1c72d7dd..5861b208 100644 --- a/ios/RCTOneSignal/RCTOneSignalEventEmitter.m +++ b/ios/RCTOneSignal/RCTOneSignalEventEmitter.m @@ -10,7 +10,7 @@ @implementation RCTOneSignalEventEmitter { BOOL _hasSetSubscriptionObserver; BOOL _hasSetPermissionObserver; BOOL _hasAddedNotificationClickListener; - BOOL _hasAddedNotificationLifecycleListener; + BOOL _hasAddedNotificationForegroundLifecycleListener; BOOL _hasAddedInAppMessageClickListener; BOOL _hasAddedInAppMessageLifecycleListener; NSMutableDictionary* _preventDefaultCache; @@ -264,7 +264,10 @@ + (void)sendEventWithName:(NSString *)name withBody:(NSDictionary *)body { } RCT_EXPORT_METHOD(addNotificationForegroundLifecycleListener) { - [OneSignal.Notifications addForegroundLifecycleListener:self]; + if (!_hasAddedNotificationForegroundLifecycleListener) { + [OneSignal.Notifications addForegroundLifecycleListener:self]; + _hasAddedNotificationForegroundLifecycleListener = true; + } } RCT_EXPORT_METHOD(onWillDisplayNotification:(OSNotificationWillDisplayEvent *)event){ @@ -424,4 +427,4 @@ + (void)sendEventWithName:(NSString *)name withBody:(NSDictionary *)body { // iOS Stub } -@end \ No newline at end of file +@end