【问题标题】:FCM IOS notificationFCM IOS 通知
【发布时间】:2020-08-19 16:52:15
【问题描述】:

当我尝试在 android 上发送通知时代码工作正常,但它不适用于 IOS 通知。得到以下错误:

{
  "results": [
    {
      "error": {
        "code": "messaging/internal-error",
        "message": "An internal error has occurred. Please retry the request."
      }
    }
  ],
  "canonicalRegistrationTokenCount": 0,
  "failureCount": 1,
  "successCount": 0,
  "multicastId": 8118740071861272000
}

这是我的代码示例,请查看并帮助我解决问题。 此外,当我尝试从云消息控制台发送通知时,我会收到通知。

    return await admin.messaging()
          .sendToDevice(deviceToken, {
   data: {
       title: 'Test Fcm',
       body: 'tesing fmc body',
       content_available: 'true',
       priority: 'high',
       action_type: 'TEST'
     },
     notification: {
       title: 'Test Fcm',
       body: 'tesing fmc body',
       content_available: 'true',
       priority: 'high'
     }
   }
  , {
   priority: "high",
   timeToLive: 60 * 60 * 24,
   contentAvailable:true,
}).catch(err => {
              console.log(err);
            
          })

【问题讨论】:

  • 您是否将 APNS 身份验证密钥上传到 Firebase 控制台?确保您已关注Configure APNS with FCM guide,并且没有任何问题。
  • 是的,我已经上传了 APNS 身份验证密钥。它工作正常,突然抛出这个错误。

标签: javascript firebase firebase-cloud-messaging firebase-admin


【解决方案1】:

我2天前就遇到过这个问题。

只需从“通知”中删除“content_available”即可。

您的 json 示例 =>

{
   data: {
       title: 'Test Fcm',
       body: 'tesing fmc body',
       content_available: 'true',
       priority: 'high',
       action_type: 'TEST'
     },
     notification: {
       title: 'Test Fcm',
       body: 'tesing fmc body',
       => content_available: 'true', // remove this
       priority: 'high'
     }
}

问候。

【讨论】:

    猜你喜欢
    • 2021-01-21
    • 2019-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-05
    • 1970-01-01
    相关资源
    最近更新 更多