方法 didInvalidatePushTokenForType 未使用 Twilio 调用过期的令牌

Method didInvalidatePushTokenForType is not calling on token expired using Twilio

我正在使用 Twilio 语音 Objective-C iOS 快速入门。我可以在创建访问令牌后注册 TwilioVoice,如下所述:-

#pragma mark - PKPushRegistryDelegate
- (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type {
    NSLog(@"pushRegistry:didUpdatePushCredentials:forType:");

    if ([type isEqualToString:PKPushTypeVoIP]) {
        self.deviceTokenString = [credentials.token description];

        [[PhoneCallModel sharedInstanse] getAccessTokenResponse:^(NSString *accessToken) {

            [[TwilioVoice sharedInstance] registerWithAccessToken:accessToken
                                                      deviceToken:self.deviceTokenString
                                                       completion:^(NSError *error) {
                                                           if (error) {
                                                               NSLog(@"An error occurred while registering: %@", [error localizedDescription]);
                                                           }
                                                           else {
                                                               NSLog(@"Successfully registered for VoIP push notifications.");
                                                           }
                                                       }];
        }];
    }
}

我已经按照 Pushkit (PKPushRegistry) 方法创建了 5 分钟的令牌

- (void)pushRegistry:(PKPushRegistry *)registry didInvalidatePushTokenForType:(PKPushType)type

应该在令牌过期后调用。但是didInvalidatePushTokenForType没有调用,试了很多次。

如何检查传入“registerWithAccessToken”的当前访问令牌是否已过期?
我想在当前访问令牌过期后使用 AccessToken 重新注册 TwilioVoice。

请帮忙,提前致谢。

这里是 Twilio 开发人员布道者。

想在这里完成一圈,如this question was also asked and may have follow up on the GitHub project for the quickstart application。以下是在 Programmable Voice SDK 团队工作的 Bobie 的回答:

The - (void)pushRegistry:(PKPushRegistry *)registry didInvalidatePushTokenForType:(PKPushType)type delegate method is called when the device token previously issued by Apple VoIP service has expired or no longer valid for use. More details in this documentation by Apple.

The main idea of using Access Token is to provide a "one-time" operation authentication, for registration requests or the signaling handshake when making outgoing calls. That being said, we still recommend that you generate access tokens with expiry equal or longer than 1 hour when making outgoing calls.

As for refreshing the registry, you actually don't have to re-register unless you have explicitly unregistered (or the PushKit token has expired). The application will still be able to receive push notifications from Twilio.

补充一下,如果您想在应用程序中进行自动访问令牌管理,则可以使用 Twilio AccessManager SDK。这是在可编程语音、聊天、视频和同步之间共享的通用 SDK。有instructions for installing it in the Chat documentation.

此页面随后显示 how to use the AccessManager with the Chat SDK。您可以替换可编程语音 SDK,但它应该可以正常工作。

如果这有帮助,请告诉我。