Node.js FCM token is empty but it's not

Viewed 24
async function sendNotif(title, body0, token) {
  return await admin.messaging().send({
    message: {
      token:
        "dHUKMkIxRbS3uIpdnA1Qef:APA91bHQd2XUpFyWzfdbKrpPV2T9b0uJx9TfKZcyF-O_oAbQ13yA5R-52t_RTb_QSPrMpxw1OV9z8sNFRth5wGuCAld_9VsKr4oRdSWsMzqhrbKcTLC2rAp5QLOUALqiTadyvyvcjTmb!",
      notification: {
        title: title,
        body: body0,
      },
      data: {
        hello: "world",
        click_action: "FLUTTER_NOTIFICATION_CLICK",
      },
      // Set Android priority to "high"
      android: {
        priority: "high",
      },
      // Add APNS (Apple) config
      apns: {
        payload: {
          aps: {
            contentAvailable: true,
          },
        },
        headers: {
          "apns-push-type": "background",
          "apns-priority": "5", // Must be `5` when `contentAvailable` is set to true.
          "apns-topic": "io.flutter.plugins.firebase.messaging", // bundle identifier
        },
      },
    },
  });
}

I am wondering why I am getting this error

errorInfo: {
  code: 'messaging/invalid-payload',
  message: 'Exactly one of topic, token or condition is required'
},

I checked the token and it's a good one i add firebase-admin library and I initialized it but it still didn't work .

so any answers?

0 Answers
Related