Node.js Twilio通知toBindings

Node.js Twilio通知toBindings,node.js,twilio,Node.js,Twilio,我对一个身份有多个绑定,比如APN和SMS。 如果我阅读并了解到,您可以通过“toBinding”属性指定要将其发送到的绑定类型?但是如果我使用这个属性,我会得到一个错误 const notificationOpts = { identity: '45A4B6D0-BBA8-4C9E-B0B8-DCA1433C1E65', toBinding: ['sms'], body: 'Knok-Knok! This is your first Notify SMS', }; client.

我对一个身份有多个绑定,比如APN和SMS。 如果我阅读并了解到,您可以通过“toBinding”属性指定要将其发送到的绑定类型?但是如果我使用这个属性,我会得到一个错误

const notificationOpts = {
  identity: '45A4B6D0-BBA8-4C9E-B0B8-DCA1433C1E65',
  toBinding: ['sms'],
  body: 'Knok-Knok! This is your first Notify SMS',
};

client.notify
  .services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
  .notifications.create(notificationOpts)
  .then(notification => console.log(notification))
  .catch(error => console.log(error));
使用上述代码时收到的错误消息

{ [Error: Can not convert incoming parameters to Notification object: Parameter 'ToBinding' is invalid]
  status: 400,
  message: 'Can not convert incoming parameters to Notification object: Parameter \'ToBinding\' is invalid',
  code: 20001,
  moreInfo: 'https://www.twilio.com/docs/errors/20001',
  detail: undefined }

这里是Twilio开发者福音传道者

toBinding
属性实际上用于向您以前没有为其创建绑定的用户发送通知。对

正如文件所说:

标签 选择要通知的绑定的标记。重复此参数可指定多个标记,最多可指定5个标记。隐式标记all可用于通知服务实例中的所有绑定。类似地,隐式标记apn、fcm、gcm、sms和facebook messenger可用于通知特定频道中的所有绑定

因此,您应该在原始示例中使用以下
notificationOpts

const notificationOpts={
标识:“45A4B6D0-BBA8-4C9E-B0B8-DCA1433C1E65”,
标签:['sms'],
正文:“Knok Knok!这是你第一条通知短信”,
};

让我知道这是否有帮助。

这里的示例与您的代码片段不同(向请求中的绑定发送通知)。