Skip to content

Commit 3d1b675

Browse files
committed
cache lastVoipToken and return it when subsequently call to registerVoipToken
1 parent ab54fd9 commit 3d1b675

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ios/RNVoipPushNotification/RNVoipPushNotificationManager.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ @implementation RNVoipPushNotificationManager
2929
RCT_EXPORT_MODULE();
3030

3131
static bool _isVoipRegistered = NO;
32+
static NSString *_lastVoipToken = @"";
3233
static NSMutableDictionary<NSString *, RNVoipPushNotificationCompletion> *completionHandlers = nil;
3334

3435

@@ -125,8 +126,10 @@ + (void)voipRegistration
125126
{
126127
if (_isVoipRegistered) {
127128
#ifdef DEBUG
128-
RCTLog(@"[RNVoipPushNotificationManager] voipRegistration is already registered");
129+
RCTLog(@"[RNVoipPushNotificationManager] voipRegistration is already registered. return _lastVoipToken = %@", _lastVoipToken);
129130
#endif
131+
RNVoipPushNotificationManager *voipPushManager = [RNVoipPushNotificationManager allocWithZone: nil];
132+
[voipPushManager sendEventWithNameWrapper:RNVoipPushRemoteNotificationsRegisteredEvent body:_lastVoipToken];
130133
} else {
131134
_isVoipRegistered = YES;
132135
#ifdef DEBUG
@@ -161,8 +164,10 @@ + (void)didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSStr
161164
[hexString appendFormat:@"%02x", bytes[i]];
162165
}
163166

167+
_lastVoipToken = [hexString copy];
168+
164169
RNVoipPushNotificationManager *voipPushManager = [RNVoipPushNotificationManager allocWithZone: nil];
165-
[voipPushManager sendEventWithNameWrapper:RNVoipPushRemoteNotificationsRegisteredEvent body:[hexString copy]];
170+
[voipPushManager sendEventWithNameWrapper:RNVoipPushRemoteNotificationsRegisteredEvent body:_lastVoipToken];
166171
}
167172

168173
// --- should be called from `AppDelegate.didReceiveIncomingPushWithPayload`

0 commit comments

Comments
 (0)