方法didInvalidatePushTokenForType没有调用使用Twilio过期的令牌 [英] Method didInvalidatePushTokenForType is not calling on token expired using Twilio

查看:137
本文介绍了方法didInvalidatePushTokenForType没有调用使用Twilio过期的令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 iOS的Twilio语音Objective-C快速入门.如下所述创建访问令牌后,我就能注册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开发人员的福音.

想在这里完成圈,因为这个问题也曾被问及可能已对快速入门应用程序的GitHub项目进行了跟踪.这是来自可编程语音SDK团队的Bobie的答案:

Apple VoIP服务先前发出的设备令牌已过期或不再有效时,将调用-(void)pushRegistry:(PKPushRegistry *)注册表didInvalidatePushTokenForType:(PKPushType)类型委托方法. Apple会在本文档中提供更多详细信息.

使用访问令牌的主要思想是提供一次性"的访问令牌.操作身份验证,用于注册请求或拨出电话时的信号交换.话虽如此,我们仍然建议您在拨打电话时生成到期时间等于或大于1小时的访问令牌.

至于刷新注册表,实际上您不必重新注册,除非您已明确注销(或PushKit令牌已过期).该应用程序仍将能够接收来自Twilio的推送通知.

只需添加此内容,如果您想在应用程序中获得自动访问令牌管理,则可以使用Twilio AccessManager SDK.这是在可编程语音,聊天,视频和同步之间共享的通用SDK.在聊天文档中有安装说明./p>

然后,此页面显示

I have created token for 5 mins, as per Pushkit (PKPushRegistry) method

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

should call after token expired. But didInvalidatePushTokenForType is not calling, tried many times.

How can I check that current access token is expired or not, passed in 'registerWithAccessToken'?
I want to re-register TwilioVoice With AccessToken after current access token expired.

Please help, thanks in advance.

解决方案

Twilio developer evangelist here.

Wanted to complete the circle here, as this question was also asked and may have follow up on the GitHub project for the quickstart application. Here's the answer from Bobie who works on the Programmable Voice SDK team:

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.

Just to add to this, if you want to get automatic access token management in your application, then you can use the Twilio AccessManager SDK. This is a common SDK that is shared among Programmable Voice, Chat, Video and Sync. There are instructions for installing it in the Chat documentation.

This page then shows how to use the AccessManager with the Chat SDK. You can substitute the Programmable Voice SDK and it should work the same though.

Let me know if this helps at all.

这篇关于方法didInvalidatePushTokenForType没有调用使用Twilio过期的令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆