You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A short tutorial about creating a custom service account and role inside of the Goolge Cloud Platform for sending a Firebase Cloud Message (FCM) from a nodejs project.
enter cloudmessaging.messages.create in the Filter table field
select cloudmessaging.messages.create
press ADD
press CREATE
go to Service Accounts
press CREATE SERVICE ACCOUNT
enter a name as well as a description
press CREATE
select your new role
press DONE
press Create key at the actions of your new service account
select JSON and press create
download the .json file
Sending a cloud message from nodejs
create an ENV variable GOOGLE_APPLICATION_CREDENTIALS pointing to your downloaded file
send a push notification from your nodejs project:
constadmin=require("firebase-admin")admin.initializeApp({credential: admin.credential.applicationDefault(),});letmessage={token: "THE CLIENT TOKEN",notification: {title: "TEST MESSAGE",body: "This is a test message.",},};admin.messaging().send(message).then((response)=>{console.log('Successfully sent message:',response);}).catch((error)=>{console.log('Error sending message:',error);});