Recently, I've been working on a new feature for my project.
But I encountered lot of issues with the back-end while implementing the feature.
// Use messaging() directly from firebase-admin import
const sendResult = await messaging().sendMulticast(multicastMessage); // <--- Error here, sendMulticast(...) do not exist on type Messaging
I'm trying to implement a push notification feature, using Firebase, Nest.js and other frameworks.
In the code I'm trying to send a notification. The error part is trying to Constructs a multicast message and sends it using messaging().sendMulticast().
You're using APIs that are no longer part of recent versions of firebase-admin since version 13. You will need to upgrade your code.
According to the examples in the documentation, firebase-admin doesn't export a function called messaging
. The examples all show use of getMessaging
.
Also, sendMulticast has been removed from recent versions of firebase-admin. The replacement is sendEachForMulticast
.
Read the release notes for the Firebase Messaging in the Admin SDK version 13:
Removed deprecated sendAll(), sendMulticast(), sendToDevice(), sendToDeviceGroup(), sendToTopic(), and sendToCondition() APIs.
This is confirmed in the API documentation for getMessaging. It returns a Messaging object which has a method sendForEachMulticast.