N
Novu3mo ago
Sapar

Using Novu to send push notifications via FCM

Hi. I try to use Novu to send push notifications via FCM. According to the docs https://docs.novu.co/integrations/providers/push/fcm I enabled the FCM integration - got my service account key from the Firebase Console, pasted the entire JSON file content in the Service Account field of the FCM provider in the integration store on Novu’s web dashboard. Then following this guide https://docs.novu.co/integrations/providers/push/fcm#setting-device-token I try to add the subscriber’s device token. And from this place there are some confusions.
15 Replies
Sapar
Sapar3mo ago
This is the guide curl code: curl -L -X PUT 'https://api.novu.co/v1/subscribers/<SUBSCRIBER_ID>/credentials' \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Authorization: ApiKey <NOVU_API_KEY>' \ -d '{ "providerId": "fcm", "credentials": { "deviceTokens" : [ "token1", "token2" ] }, "integrationIdentifier": "fcm-MnGLxp8uy" }' And this is the api reference:
Sapar
Sapar3mo ago
No description
Sapar
Sapar3mo ago
There are a lot of unfamiliar options that do not correspond with the guide. And there is no another full guide to send a push notifications that explains all the params and properties For example what is providerId, where do I get it from?
Pawan Jain
Pawan Jain3mo ago
providerId is fcm This api is used for storing other credentials as well. That's why you see more properties with deviceTokens
Sapar
Sapar3mo ago
cannot type "fcm" here
No description
Pawan Jain
Pawan Jain3mo ago
it is of enum type you can select from the dropdown
Sapar
Sapar3mo ago
the dropdown is empty
Pawan Jain
Pawan Jain3mo ago
let me check
Sapar
Sapar3mo ago
yes please, waiting for your response
Pawan Jain
Pawan Jain3mo ago
Looks like there is some issue Can I share example cURL here?
curl -L -X PUT 'https://api.novu.co/v1/subscribers/<SUBSCRIBER_ID>/credentials' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: ApiKey <YOUR_API_KEY>' \
-d '{
"providerId": "fcm",
"credentials": {
"deviceTokens": [
"DEVICE_TOKEN_1",
"DEVICE_TOKEN_2"
]
},
"integrationIdentifier": "<INTEGRATION_IDENTIFIER>"
}'
curl -L -X PUT 'https://api.novu.co/v1/subscribers/<SUBSCRIBER_ID>/credentials' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: ApiKey <YOUR_API_KEY>' \
-d '{
"providerId": "fcm",
"credentials": {
"deviceTokens": [
"DEVICE_TOKEN_1",
"DEVICE_TOKEN_2"
]
},
"integrationIdentifier": "<INTEGRATION_IDENTIFIER>"
}'
Sapar
Sapar3mo ago
Can you explain please "deviceTokens"? Where do I get them from?
Pawan Jain
Pawan Jain3mo ago
deviceTokens are generated on the client side. When you go to a website that can send push notification. It asks for push notification permission. when you allow push notification permission to that website, a devicetoken is generated. So you need to handle this in client side and store it in Novu using our api or SDK https://v0.x-docs.novu.co/guides/FCM-iOS-Novu/how-to-send-PUSH-notifications-to-iOS-devices-with-FCM-using-Novu https://v0.x-docs.novu.co/guides/fcm-flutter-novu/how-to-send-push-notifications-to-flutter-apps-with-fcm-using-Novu https://v0.x-docs.novu.co/guides/novu-fcm-web
Sapar
Sapar3mo ago
can it be any string just for testing needs?
Pawan Jain
Pawan Jain3mo ago
No, it should be a valid FCM devicetoken, generated using credentials of same project @Sapar Did you manage to send push notification using Novu?
Want results from more Discord servers?
Add your server