gpt4 book ai didi

ios - 方法 didInvalidatePushTokenForType 未调用使用 Twilio 过期的 token

转载 作者:行者123 更新时间:2023-12-01 19:51:56 31 4
gpt4 key购买 nike

我正在使用 适用于 iOS 的 Twilio Voice Objective-C 快速入门 .我可以在创建访问 token 后注册 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 分钟的 token
- (void)pushRegistry:(PKPushRegistry *)registry didInvalidatePushTokenForType:(PKPushType)type

应该在 token 过期后调用。但是 didInvalidatePushTokenForType 不叫,试了很多次。

如何检查当前访问 token 是否已过期,是否在“registerWithAccessToken”中传递?
当前访问 token 过期后,我想使用 AccessToken 重新注册 TwilioVoice。


请帮助,提前谢谢。

最佳答案

Twilio 开发人员布道者在这里。
想在这里完成圈子,如this question was also asked and may have follow up on the GitHub project for the quickstart application .以下是在可编程语音 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.


除此之外,如果您想在应用程序中获得自动访问 token 管理,那么您可以使用 Twilio AccessManager开发工具包。这是可编程语音、聊天、视频和同步之间共享的通用 SDK。有 instructions for installing it in the Chat documentation .
然后此页面显示 how to use the AccessManager with the Chat SDK .您可以替换可编程语音 SDK,但它应该可以正常工作。
让我知道这是否有帮助。

关于ios - 方法 didInvalidatePushTokenForType 未调用使用 Twilio 过期的 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45323827/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com