N
Novu5d ago
loup

How use FCM push in NextJS app

Okay I dont understand how we implement FCM push notification using novu in NextJS app. Because Ive added FCM to my workflow but I never receive the notification in my NextJS . My FCM (with service workers) integration seems to be good because Ive test it and its workring. FCM seems to use tokeen to authenticate a user but how novu know this token ?
2 Replies
loup
loupOP5d ago
OKay we have to set device token : https://docs.novu.co/integrations/providers/push/fcm#setting-device-token But how sync every token with every user ?
Novu
Firebase Cloud Messaging (FCM) - Novu
Learn how to use the Firebase Cloud Messaging (FCM) provider to send push notifications using Novu
Pawan Jain
Pawan Jain4d ago
@loup above doc section requires subscriberid , providerId and deviceTokens here subscriberId is unique for one user so devuceTokens can be stored for all users.
import {
Novu,
PushProviderIdEnum
} from '@novu/node';

const novu = new Novu("<NOVU_SECRET_KEY>");

await novu.subscribers.setCredentials(
'subscriberId',
PushProviderIdEnum.FCM,
{ deviceTokens: ['token1', 'token2'] },
'fcm-MnGLxp8uy'
);
import {
Novu,
PushProviderIdEnum
} from '@novu/node';

const novu = new Novu("<NOVU_SECRET_KEY>");

await novu.subscribers.setCredentials(
'subscriberId',
PushProviderIdEnum.FCM,
{ deviceTokens: ['token1', 'token2'] },
'fcm-MnGLxp8uy'
);
Want results from more Discord servers?
Add your server