To test the example app, clone the project and add the firebase_options.dart with your firebase options file in lib/firebase_options.dart.
Then, build the app and run it. The app is set to receive notifications.
-
- Open the Firebase Console, and then go to Build > Messaging from the left panel. Choose Create first campaign, and then Firebase notification message.
- Set the title, body and image (if any), and then press Send test message, paste the FCM token which you can get by running the example app and copy it, and then send the notification.
-
- Clone this notification-sender project,
- Download the service account key file by visiting the Google Cloud Service Accounts Panel and select the correct project, and add a new key or use an existing one if you already have.
- Create a
.envfile in the root folder. Add keysFIREBASE_PROJECT_ID,CLIENT_EMAILandPRIVATE_KEYin the .env file. - Get the FCM token by running the example app, and pass it to the
fcm_tokensproperty ofsendNotificationfunction in the index.ts file. - Run
npm start.