Firebase cloud messaging error mismatched-credential

Viewed 242

I hate how firebase very basic hello worlds doesn't work and then we must guess the problems since the documentation is poor as hell..

i'm trying to send a very simple message to a topic with FCM

    const messaging = require('firebase-admin').initializeApp({
   serviceAccountId: 'fcm-publisher@igibo-b0b27.iam.gserviceaccount.com',
   projectId: "igibo-b0b27",
   messagingSenderId : 'fcm_publisher',
   appId : 'bla bla bla' //correct apID
}).messaging();


exports.sm_jivo_webhook = (req, res) => {

var message = {
  data: {
    activity: 'chat',
  },
  notification: {
    title: 'Resposta do suporte',
    body: 'Volte ao chat para verificar a resposta as suas dúvidas'
  },
  topic: '46f5b99a-5619-3a6b-a0e7-7ca1757b8930'
};


messaging.send(message)
  .then((response) => {
  res.status(200).send(JSON.stringify(response));  })
  .catch((error) => {
   res.status(200).send(JSON.stringify(error));
  });

};

the topic is right
the projectId is right
the serviceAccuontId is right and is an account with admin privileges to fcm

enter image description here

but still on running this code i get:

{"code":"messaging/mismatched-credential","message":"The caller does not have permission"}

according to this documentation piece of crap
https://firebase.google.com/docs/cloud-messaging/send-message#admin_sdk_error_reference

messaging/mismatched-credential -> The credential used to authenticate this SDK does not have permission to send messages to the device corresponding to the provided registration token. Make sure the credential and registration token both belong to the same Firebase project. See Add Firebase to your app for documentation on how to authenticate the Firebase Admin SDKs.

what am i doing wrong?
does anyone have a real hello world for this sdk?

0 Answers
Related