@@ -60,10 +60,30 @@ @implementation RNVoipPushNotificationManager
6060RCT_EXPORT_MODULE ();
6161
6262@synthesize bridge = _bridge;
63+ static NSMutableDictionary <NSString *, RNVoipPushNotificationCompletion> *completionHandlers = nil ;
64+
65+ + (NSMutableDictionary *)completionHandlers {
66+ if (completionHandlers == nil ) {
67+ completionHandlers = [NSMutableDictionary new ];
68+ }
69+ return completionHandlers;
70+ }
6371
6472- (void )dealloc
6573{
6674 [[NSNotificationCenter defaultCenter ] removeObserver: self ];
75+
76+ // --- invoke complete() and remove for all completionHanders
77+ for (NSString *uuid in [RNVoipPushNotificationManager completionHandlers ]) {
78+ RNVoipPushNotificationCompletion completion = [[RNVoipPushNotificationManager completionHandlers ] objectForKey: uuid];
79+ if (completion) {
80+ dispatch_async (dispatch_get_main_queue (), ^{
81+ completion ();
82+ });
83+ }
84+ }
85+
86+ [[RNVoipPushNotificationManager completionHandlers ] removeAllObjects ];
6787}
6888
6989- (void )setBridge : (RCTBridge *)bridge
@@ -190,6 +210,31 @@ - (void)handleRemoteNotificationReceived:(NSNotification *)notification
190210 body: notification.userInfo];
191211}
192212
213+ + (void )addCompletionHandler : (NSString *)uuid completionHandler : (RNVoipPushNotificationCompletion)completionHandler
214+ {
215+ self.completionHandlers [uuid] = completionHandler;
216+ }
217+
218+ + (void )removeCompletionHandler : (NSString *)uuid
219+ {
220+ self.completionHandlers [uuid] = nil ;
221+ [self .completionHandlers removeObjectForKey: uuid];
222+ }
223+
224+ RCT_EXPORT_METHOD (onVoipNotificationCompleted:(NSString *)uuid)
225+ {
226+ RNVoipPushNotificationCompletion completion = [[RNVoipPushNotificationManager completionHandlers ] objectForKey: uuid];
227+ if (completion) {
228+ [RNVoipPushNotificationManager removeCompletionHandler: uuid];
229+ dispatch_async (dispatch_get_main_queue (), ^{
230+ NSLog (@" [RNVoipPushNotificationManager] onVoipNotificationCompleted() complete(). uuid = %@ " , uuid);
231+ completion ();
232+ });
233+ } else {
234+ NSLog (@" [RNVoipPushNotificationManager] onVoipNotificationCompleted() not found. uuid = %@ " , uuid);
235+ }
236+ }
237+
193238RCT_EXPORT_METHOD (requestPermissions:(NSDictionary *)permissions)
194239{
195240 if (RCTRunningInAppExtension ()) {
0 commit comments