【问题标题】:How to get Twilio Notify to work with firebase FCM如何让 Twilio Notify 与 firebase FCM 一起使用
【发布时间】:2021-10-22 18:42:03
【问题描述】:

我一直关注Twilio firebase quickstart 直到第 7 点,这实际上包括最终的推送通知测试,但我对“身份”和“地址”之间的绑定有点困惑。据我了解,地址只是之前收到的令牌,所以我尝试只注册它们(老实说之前没有使用注册)

messaging.getToken()
   .then(function(currentToken) {
      if (currentToken) {
        console.log('Token received: ', currentToken)
        const identity = 'myidentity'
        const address = currentToken
      
        register(identity, address)
      }
   })

不幸的是 register 需要类型“Hooks”而不是字符串(消息是“'string'类型的参数不可分配给'Hooks | undefined'.Vetur(2345)类型的参数”)

我错过了什么?

【问题讨论】:

    标签: javascript firebase firebase-cloud-messaging twilio


    【解决方案1】:

    这里是 Twilio 开发者宣传员。

    register 函数实际上是在the notify_actions.js file that is part of the example repo 中定义的。它看起来像:

    function register(identity, address){
        var url = "http://127.0.0.1:3000/register";
        
        data = {
            'identity': identity,
            'address': address,
            'binding_type': 'fcm'
        }
        postRequest(url, data);
    }
    

    postRequestXMLHttpRequest 的包装器,用于向您的服务器发出请求。这旨在首先将身份和地址/令牌发送到您的服务器,然后发送到 Twilio Notify API 以使用设备令牌注册身份。您可以将通知快速入门使用的see this in the SDK starter back-end 转换为create the binding

    我不确定您的 register 函数来自哪里,或者为什么它会给出与“Hooks”有关的错误,但这是它应该做的。希望这能有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-09
      • 1970-01-01
      • 2021-04-28
      • 1970-01-01
      • 1970-01-01
      • 2017-03-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多