[英]Error in Push Notifications while registering for iOS Twilio Voice Client
I am getting the following error while trying to register a user for the Twilio Voice client: 我在尝试为Twilio Voice客户端注册用户时收到以下错误:
[ERROR VoiceClient] Inside register:deviceToken:completion:, failed to register for Twilio push notifications. Error:Failed to register. Code: 6.
Here is the setup: 这是设置:
IpMessagingGrant
object. IpMessagingGrant
对象。 VoiceClient.sharedInstance().register(withAccessToken: self.accessToken, deviceToken: self.voipToken)
VoiceClient.sharedInstance().register(withAccessToken: self.accessToken, deviceToken: self.voipToken)
Is Twilio really supporting VoIP pushes? Twilio真的支持VoIP推送吗? If yes, what could be wrong with this setup?
如果是,这个设置可能有什么问题?
Thanks, Guven. 谢谢,Guven。
======= Edit after Viktor's guidance: I now manually create the VoiceGrant. ======= Viktor指导后编辑:我现在手动创建VoiceGrant。 I set the value of the key property to
'voice'
. 我将key属性的值设置为
'voice'
。 Here is what the grant looks like: 这是赠款的样子:
{
outgoing_application_sid: 'APXX',
push_credential_sid: 'CRXX',
endpoint_id: 'XX'
}
Still getting the registration error. 仍然收到注册错误。
I have also tried this format since this is how it looks in 2.11.0 version: 我也试过这种格式,因为这是它在2.11.0版本中的样子:
{ outgoing: { application_sid: 'APXX' },
push_credential_sid: 'CRXX',
endpoint_id: 'XX'
}
Any ideas where the problem might be? 任何可能出现问题的想法? Attaching the cloud code as well:
附加云代码:
var accessToken = new twilio.AccessToken("ACXX", "SKXX", "PPXX", accessTokenOptions);
var voiceGrantConfig = {"outgoingApplicationSid": "APXX",
"endpointId": clientName,
"pushCredentialSid": "CRXX"};
var voiceGrant = new VoiceGrant(voiceGrantConfig);
voiceGrant.key = "voice";
console.log(voiceGrant.toPayload());
accessToken.addGrant(voiceGrant);
var token = accessToken.toJwt();
Edit 2 : I have actually upgraded to twilio-node 2.11.0 and still getting the error. 编辑2 :我实际上已升级到twilio-node 2.11.0并仍然收到错误。 Here is the access token right before generating the jwt.
这是生成jwt之前的访问令牌。
AccessToken {
accountSid: 'ACXX',
keySid: 'SKXX',
secret: 'PPXX',
ttl: 86400,
identity: undefined,
nbf: undefined,
grants:
[ VoiceGrant {
outgoingApplicationSid: 'APXX',
outgoingApplicationParams: undefined,
pushCredentialSid: 'CRXX',
endpointId: 'XX' } ] }
[Edited based on feedback from Guven] [根据Guven的反馈编辑]
You need a "voice" grant. 你需要一个“声音”补助金。 Otherwise your requests will be denied to the Voice product.
否则,您的请求将被拒绝使用Voice产品。 You either need to manually add that section to the JSON before signing it or you need to upgrade to the 2.11.0 version.
您需要在签名之前手动将该部分添加到JSON,或者需要升级到2.11.0版本。 Specifically your token needs to look like this:
具体来说,您的令牌需要如下所示:
{
"sub": "ACxxxx",
"iss": "SKxxxx",
"grants": {
"voice": {
"outgoing": {
"application_sid": "APxxxx"
},
"push_credential_sid": "CRxxxxx"
},
"identity": "voice_test"
},
"jti": "SKxxxxx",
"exp": 1479315711
}
Note, also the "identity" element as well. 注意,也是“identity”元素。 This is the identifier of your user.
这是您的用户的标识符。 Typically its username or an ID of the user record in your system.
通常是其用户名或系统中用户记录的ID。
Checkout the quickstart app for a code sample for generating the right token (it's in Python but should give you a good idea of how to get started). 查看快速入门应用程序以获取用于生成正确令牌的代码示例(它在Python中,但应该让您了解如何开始)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.