The @aracna/fcm package depends on the @aracna/core package as a peer dependency, which is required for it to function.
This package works only on Node.js.
Use to receive messages
The @aracna/fcm library is capable of registering to Firebase Cloud Messaging and listen to incoming messages through a socket connection with Google MTalk.
- Create a new project on the Firebase Console.
- Add a new web app to the project.
- Create a new web push certificate under the Cloud Messaging tab of the project settings.
- Create a new auth secret and ECDH key pair with the generateFcmAuthSecret and createFcmECDH functions.
- Store the auth secret and ECDH key pair securely.
- Register to Firebase Cloud Messaging with the registerToFCM function.
- Store the ACG ID, ACG security token and FCM token.
- Create a new FcmClient instance using the values from the previous steps.
- Connect with the
connect
method of the client.
- Listen to incoming messages with the
on
method of the client, see the FcmClient docs for more information.
Use to send messages
The @aracna/fcm library is capable of sending messages to Firebase Cloud Messaging.
- Create a new project on the Firebase Console.
- Create a new private key under the Service Accounts tab of the project settings.
- Use the sendFcmMessage function with the
google-service-account.json
file.
Migrate from push-receiver
The @aracna/fcm library is almost a drop-in replacement for the push-receiver library.
- Add a new web app to the Firebase project on the Firebase Console.
- Create a new web push certificate under the Cloud Messaging tab of the project settings.
- Register to Firebase Cloud Messaging with the registerToFCM function using the same values that were used with the push-receiver library.
- Store the FCM token, this one is generated with the latest APIs from Google/Firebase.
- Create a new FcmClient instance using the values from the previous steps.
- Connect with the
connect
method of the client.
- Listen to incoming messages with the
on
method of the client, see the FcmClient docs for more information.