N
Novu9mo ago
korayaggul

How to use onesignal push notification for novu ?

I want to use One Signal for push notification. I entered the necessary information, but I get this error. Can you help me on how to do it? I looked here but I didn't understand what it does. It wants me to re-set someone who is already subscribed. I tried it but it didn't work. https://docs.novu.co/channels-and-providers/push/onesignal
const res = await novu.subscribers.get(userProfile.id.toString());
console.log("zxcresponse",res.data)
await novu.subscribers.setCredentials(res.data.data.subscriberId, PushProviderIdEnum.OneSignal, {
// Your user's unique 'player_id' from OneSignal
deviceTokens: [res.data.data.id],
});
const res = await novu.subscribers.get(userProfile.id.toString());
console.log("zxcresponse",res.data)
await novu.subscribers.setCredentials(res.data.data.subscriberId, PushProviderIdEnum.OneSignal, {
// Your user's unique 'player_id' from OneSignal
deviceTokens: [res.data.data.id],
});
No description
8 Replies
korayaggul
korayaggulOP9mo ago
I updated the deviceTokens section
const res = await novu.subscribers.get(userProfile.id.toString());
console.log("zxcresponse",res.data.data.channels[0].credentials.deviceTokens)
await novu.subscribers.setCredentials(res.data.data.subscriberId, PushProviderIdEnum.OneSignal, {
// Your user's unique 'player_id' from OneSignal
deviceTokens: res.data.data.channels[0].credentials.deviceTokens,
});
const res = await novu.subscribers.get(userProfile.id.toString());
console.log("zxcresponse",res.data.data.channels[0].credentials.deviceTokens)
await novu.subscribers.setCredentials(res.data.data.subscriberId, PushProviderIdEnum.OneSignal, {
// Your user's unique 'player_id' from OneSignal
deviceTokens: res.data.data.channels[0].credentials.deviceTokens,
});
Pawan Jain
Pawan Jain9mo ago
@korayaggul Could you please share the environmentId from settings?
korayaggul
korayaggulOP9mo ago
65d248cae035efad38c5d6e9
Pawan Jain
Pawan Jain9mo ago
@korayaggul Thanks for sharing the environmentId Above error comes due to missing deviceTokens for a subscriber in case of push step I can see in logs that subscriberId "2" does not have credentials set for onesignal Could you please check from your end?
korayaggul
korayaggulOP9mo ago
No description
Novu_Bot
Novu_Bot9mo ago
@korayaggul, you just advanced to level 2!
korayaggul
korayaggulOP9mo ago
@Pawan Jain I can map Novu IDs differently with OneSignal, it does not match automatically.
Pawan Jain
Pawan Jain9mo ago
No, if you fetch a subscriber using get api then does it contain channel field and onesignal credentials set?
Want results from more Discord servers?
Add your server