diff --git a/native/ios/Comm.xcodeproj/project.pbxproj b/native/ios/Comm.xcodeproj/project.pbxproj --- a/native/ios/Comm.xcodeproj/project.pbxproj +++ b/native/ios/Comm.xcodeproj/project.pbxproj @@ -205,6 +205,8 @@ CB38F2BE286C6C980010535C /* DeleteEntryMessageSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DeleteEntryMessageSpec.h; path = PersistentStorageUtilities/MessageOperationsUtilities/MessageSpecs/DeleteEntryMessageSpec.h; sourceTree = ""; }; CB38F2BF286C6C980010535C /* UpdateRelationshipMessageSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UpdateRelationshipMessageSpec.h; path = PersistentStorageUtilities/MessageOperationsUtilities/MessageSpecs/UpdateRelationshipMessageSpec.h; sourceTree = ""; }; CB3C621327CE66540054F24C /* libEXSecureStore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libEXSecureStore.a; sourceTree = BUILT_PRODUCTS_DIR; }; + CB7EF17B295C580500B17035 /* CommIOSNotificationsBridgeQueue.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = CommIOSNotificationsBridgeQueue.mm; path = Comm/CommIOSNotifications/CommIOSNotificationsBridgeQueue.mm; sourceTree = ""; }; + CB7EF17C295C580500B17035 /* CommIOSNotificationsBridgeQueue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CommIOSNotificationsBridgeQueue.h; path = Comm/CommIOSNotifications/CommIOSNotificationsBridgeQueue.h; sourceTree = ""; }; CB90951929531663002F2A7F /* CommIOSNotifications.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommIOSNotifications.h; path = Comm/CommIOSNotifications/CommIOSNotifications.h; sourceTree = ""; }; CBDEC69928ED859600C17588 /* GlobalDBSingleton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GlobalDBSingleton.h; sourceTree = ""; }; CBDEC69A28ED867000C17588 /* GlobalDBSingleton.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = GlobalDBSingleton.mm; path = Comm/GlobalDBSingleton.mm; sourceTree = ""; }; @@ -556,6 +558,8 @@ CB90951729531647002F2A7F /* CommIOSNotifications */ = { isa = PBXGroup; children = ( + CB7EF17C295C580500B17035 /* CommIOSNotificationsBridgeQueue.h */, + CB7EF17B295C580500B17035 /* CommIOSNotificationsBridgeQueue.mm */, CB90951929531663002F2A7F /* CommIOSNotifications.h */, ); name = CommIOSNotifications; diff --git a/native/ios/Comm/CommIOSNotifications/CommIOSNotificationsBridgeQueue.h b/native/ios/Comm/CommIOSNotifications/CommIOSNotificationsBridgeQueue.h new file mode 100644 --- /dev/null +++ b/native/ios/Comm/CommIOSNotifications/CommIOSNotificationsBridgeQueue.h @@ -0,0 +1,13 @@ +#import + +@interface CommIOSNotificationsBridgeQueue : NSObject + +@property BOOL jsReady; +@property NSDictionary *openedRemoteNotification; + ++ (nonnull instancetype)sharedInstance; + +- (void)putNotification:(NSDictionary *)notifInfo; +- (void)processNotifications:(void (^)(NSDictionary *))block; + +@end diff --git a/native/ios/Comm/CommIOSNotifications/CommIOSNotificationsBridgeQueue.mm b/native/ios/Comm/CommIOSNotifications/CommIOSNotificationsBridgeQueue.mm new file mode 100644 --- /dev/null +++ b/native/ios/Comm/CommIOSNotifications/CommIOSNotificationsBridgeQueue.mm @@ -0,0 +1,40 @@ +#import "CommIOSNotificationsBridgeQueue.h" + +@implementation CommIOSNotificationsBridgeQueue + +NSMutableArray *commNotificationsQueue; + ++ (nonnull instancetype)sharedInstance { + static CommIOSNotificationsBridgeQueue *sharedInstance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedInstance = [self new]; + }); + + return sharedInstance; +} + +- (instancetype)init { + commNotificationsQueue = [NSMutableArray new]; + self.jsReady = NO; + return self; +} + +- (void)putNotification:(NSDictionary *)notifInfo { + if (!commNotificationsQueue) { + return; + } + [commNotificationsQueue addObject:notifInfo]; +} + +- (void)processNotifications:(void (^)(NSDictionary *))block { + if (!commNotificationsQueue) { + return; + } + for (id notifInfo in commNotificationsQueue) { + block(notifInfo); + } + commNotificationsQueue = nil; +} + +@end