I'm sharing my code, I've uploaded 10,000 ads, but I still don't know. I've been getting this error for a while, but all my tracks are ok.
The error I get:
ERROR: Firebase Messaging Error: An error occurred while trying to authenticate to the FCM servers. Make sure that the credentials used to authenticate this SDK have the appropriate permissions.
But;
await admin.messaging().send Multicast(message);
i receive the sent statement, but the notification does not arrive. I will also send you two different codes.
NOT WORKING
exports.sendNotificationAdmin = functions.firestore.document('ilanlar/{ilanNumarasi}').onCreate(async (snap, context) =\> {
const dataListing = snap.data();
const userTokens = \['cYZPopVmaEF9mm0KCUZLcJ:APA91bEPOKDRs6xJLLiGcHDzascKL9LGSefAy7Hfa7vmVX-76bsH4uCrWTFmhvrMpYw-4unYzcictRd5hpzgttd_AKsPpxCKFCGljysUBHe4cBYsBRcL-g7AItsMVTs6wuuOov28mF9y'\];
const isActive = dataListing.isActive;
if (isActive == 0){
const message = {
notification: {
title: 'Yeni ilan eklendi!',
body: 'Lütfen Onaylayın!',
}
};
try {
const response = await admin.messaging().sendToDevice(userTokens, message);
console.log("Bildirim Gönderildi!");
} catch (error) {
console.error("Bildirim HATASI:", error);
}
} else {
console.log('isActive Değeri 0 değil.');
}
});
working but not sending notifications :
I explained above that I tried two types of ways, but I couldn't get on one way. sendToDevice gives a permission error, but sendMulticast does not, but does not send a notification.