Send notifications to users or topics using Google's Firebase Cloud Messaging service.
Send FCM notifications from Strapi.
npm install strapi-plugin-fcm
yarn add strapi-plugin-fcm
cd /<path-to-your-strapi-project>/src
# create plugins folder if not exists
# mkdir plugins
# go to plugins folder
cd plugins
# clone the plugin code into a folder and skip the prefix
git clone https://github.com/itisnajim/strapi-plugin-fcm.git strapi-plugin-fcm
# install dependencies
cd strapi-plugin-fcm && yarn install # or npm install
<root>/config/plugins.js
.1module.exports = {
2 // ...
3 'strapi-plugin-fcm': {
4 enabled: true,
5 resolve: './src/plugins/strapi-plugin-fcm' // path to plugin folder
6 },
7 // ...
8}
# back to project root and build the plugin
yarn build # or npm run build
# start
yarn develop # or npm run develop
Past the content of your downloaded service account json file into FCM Plugin Configuration > serviceAccount. (like in the picture below, then you may need to restart the server)
In the same interface 'FCM Plugin Configuration', optionally you can provide where the devices tokens are stored, in the picture example above, I store them in User -> deviceToken (strapi generate the users database table with the name up_users).
Optionally you can provide all the topics you have, in the 'FCM Topic' collection type (via the dashboard or via the api - Post requests).
1{
2 "data": {
3 "title": "OKey",
4 "body": "Test body",
5 "image": "",
6 "payload": "",
7 "targetType": "topics",
8 //or "targetType": "tokens",
9 "target": "client_android",
10 //or multiple topics "target": "client_android,client_ios",
11 //or "target": "eyJhbGciOiJFUzI1...",
12 //publishedAt: null //<<- uncomment this if you want to just add an entry as a draft to 'FCM Notification' collection without publishing and sending FCM.
13 }
14}
1{
2 "data": [{...entry1}, {...entry2}, {...entry3}, ...]
3}
If you have saved the entries in the FCM Notification collection as drafts, you can scheduled them to be sent to FCM at a later time.
npm install strapi-plugin-fcm
Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.