From 6803f4978ffbc800f23a93645f58a438b23bb9d6 Mon Sep 17 00:00:00 2001 From: Eesa Date: Wed, 15 Nov 2023 14:01:03 +0400 Subject: [PATCH 1/2] Update RCTOneSignalEventEmitter.m to fix duplicate listeners --- ios/RCTOneSignal/RCTOneSignalEventEmitter.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ios/RCTOneSignal/RCTOneSignalEventEmitter.m b/ios/RCTOneSignal/RCTOneSignalEventEmitter.m index 1e459ae1..45a56d0f 100644 --- a/ios/RCTOneSignal/RCTOneSignalEventEmitter.m +++ b/ios/RCTOneSignal/RCTOneSignalEventEmitter.m @@ -264,7 +264,10 @@ + (void)sendEventWithName:(NSString *)name withBody:(NSDictionary *)body { } RCT_EXPORT_METHOD(addNotificationForegroundLifecycleListener) { - [OneSignal.Notifications addForegroundLifecycleListener:self]; + if (!_hasAddedNotificationLifecycleListener) { + [OneSignal.Notifications addForegroundLifecycleListener:self]; + _hasAddedNotificationLifecycleListener = true; + } } RCT_EXPORT_METHOD(onWillDisplayNotification:(OSNotificationWillDisplayEvent *)event){ @@ -419,4 +422,4 @@ + (void)sendEventWithName:(NSString *)name withBody:(NSDictionary *)body { // iOS Stub } -@end \ No newline at end of file +@end From e43f4fe045ac3453c12af7df0987cf538ed12205 Mon Sep 17 00:00:00 2001 From: Eesa Date: Thu, 16 Nov 2023 08:11:46 +0400 Subject: [PATCH 2/2] chore: rename check name --- ios/RCTOneSignal/RCTOneSignalEventEmitter.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ios/RCTOneSignal/RCTOneSignalEventEmitter.m b/ios/RCTOneSignal/RCTOneSignalEventEmitter.m index 45a56d0f..053386c9 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,9 +264,9 @@ + (void)sendEventWithName:(NSString *)name withBody:(NSDictionary *)body { } RCT_EXPORT_METHOD(addNotificationForegroundLifecycleListener) { - if (!_hasAddedNotificationLifecycleListener) { + if (!_hasAddedNotificationForegroundLifecycleListener) { [OneSignal.Notifications addForegroundLifecycleListener:self]; - _hasAddedNotificationLifecycleListener = true; + _hasAddedNotificationForegroundLifecycleListener = true; } }