简体   繁体   English

注册iOS Twilio语音客户端时推送通知出错

[英]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: 这是设置:

  • Push credentials have been registered with Twilio. 推送凭证已在Twilio注册。 A VoIP Push certificate has been registered and those kind of pushes are only in Production mode. 已注册VoIP推送证书,这种推送仅在生产模式下。 Let's say the app ID is "com.bundle.appIDX". 假设应用ID为“com.bundle.appIDX”。
  • The server side has been setup so that the correct push credentials are fed to the IpMessagingGrant object. 已设置服务器端,以便将正确的推送凭据提供给IpMessagingGrant对象。
  • At the client side, the following piece of code is executed: VoiceClient.sharedInstance().register(withAccessToken: self.accessToken, deviceToken: self.voipToken) 在客户端,执行以下代码: VoiceClient.sharedInstance().register(withAccessToken: self.accessToken, deviceToken: self.voipToken)
  • This immediately fails with the error above. 这会立即失败并出现上述错误。
  • Using version '=2.0.0-beta4' for TwilioVoiceClient, and using version '2.9.1' for twilio-node server side component ( https://github.com/twilio/twilio-node/tree/2.9.1 ). 对TwilioVoiceClient使用版本'= 2.0.0-beta4',对twilio-node服务器端组件使用版本'2.9.1'( https://github.com/twilio/twilio-node/tree/2.9.1 )。
  • Tried playing with "Use this credential for sending to a sandbox APN" option and no result. 尝试使用“使用此凭据发送到沙箱APN”选项,但没有结果。
  • Tried using both development and provisioning profiles at the client side for the app ID "com.bundle.appIDX". 尝试在客户端使用开发和配置配置文件来获取应用程序ID“com.bundle.appIDX”。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM