diff --git a/ios/RNVoipPushNotification/RNVoipPushNotificationManager.m b/ios/RNVoipPushNotification/RNVoipPushNotificationManager.m index 2699a77..d84e59a 100644 --- a/ios/RNVoipPushNotification/RNVoipPushNotificationManager.m +++ b/ios/RNVoipPushNotification/RNVoipPushNotificationManager.m @@ -11,10 +11,8 @@ #import "RNVoipPushNotificationManager.h" #import -#import #import #import -#import NSString *const RNVoipPushRemoteNotificationsRegisteredEvent = @"RNVoipPushRemoteNotificationsRegisteredEvent"; NSString *const RNVoipPushRemoteNotificationReceivedEvent = @"RNVoipPushRemoteNotificationReceivedEvent"; @@ -29,6 +27,7 @@ @implementation RNVoipPushNotificationManager RCT_EXPORT_MODULE(); static bool _isVoipRegistered = NO; +static NSString *_lastVoipToken = @""; static NSMutableDictionary *completionHandlers = nil; @@ -125,8 +124,10 @@ + (void)voipRegistration { if (_isVoipRegistered) { #ifdef DEBUG - RCTLog(@"[RNVoipPushNotificationManager] voipRegistration is already registered"); + RCTLog(@"[RNVoipPushNotificationManager] voipRegistration is already registered. return _lastVoipToken = %@", _lastVoipToken); #endif + RNVoipPushNotificationManager *voipPushManager = [RNVoipPushNotificationManager allocWithZone: nil]; + [voipPushManager sendEventWithNameWrapper:RNVoipPushRemoteNotificationsRegisteredEvent body:_lastVoipToken]; } else { _isVoipRegistered = YES; #ifdef DEBUG @@ -161,8 +162,10 @@ + (void)didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSStr [hexString appendFormat:@"%02x", bytes[i]]; } + _lastVoipToken = [hexString copy]; + RNVoipPushNotificationManager *voipPushManager = [RNVoipPushNotificationManager allocWithZone: nil]; - [voipPushManager sendEventWithNameWrapper:RNVoipPushRemoteNotificationsRegisteredEvent body:[hexString copy]]; + [voipPushManager sendEventWithNameWrapper:RNVoipPushRemoteNotificationsRegisteredEvent body:_lastVoipToken]; } // --- should be called from `AppDelegate.didReceiveIncomingPushWithPayload`