N
Novu2mo ago
ayomide

Override Apns in FCM

From the docs stated in the below link , the overrides field supports apns. but when i tried to use it, i get Object literal may only specify known properties, and 'apns' does not exist in type 'ITriggerOverrideFCM'.ts. i also did my findings in the overrides supported fields and truly apns isn't included. What am trying to do is to send push notification for both ios and android using fcm. https://docs.novu.co/channels-and-providers/push/fcm#sdk-trigger-example
Novu
Firebase Cloud Messaging (FCM) - Novu
Learn how to use the Firebase Cloud Messaging (FCM) provider to send push notifications using Novu
12 Replies
Ask Inkeep
Ask Inkeep2mo ago
Hi @ayomide, I'm an AI assistant for Novu. While a team member reviews this question, I'll see if I can find relevant sources for your question. ----------------------------- While I generate an answer, here are some sources that might be helpful: * Firebase Cloud Messaging (FCM) * How to send PUSH notifications to iOS devices with FCM using Novu * [NV-1615] Feature: FCM platform specific parameters * Bug Report: FCM push notification overrides are only applied to first device token -----------------------------
Ask Inkeep
Ask Inkeep2mo ago
Answer It seems like there might be a misunderstanding or an inconsistency in the documentation regarding the implementation of the apns field in the overrides for FCM with Novu. According to the Novu documentation, you should be able to use apns in the overrides field when configuring FCM for both iOS and Android notifications. Here's an example of how you can structure the overrides object including apns configurations:
const novu = new Novu("<NOVU_API_KEY>");

novu.trigger("<WORKFLOW_TRIGGER_IDENTIFIER>", {
to: {
subscriberId: "<SUBSCRIBER_ID>",
},
payload: {
abc: "def",
},
overrides: {
fcm: {
apns: {
headers: {
"apns-priority": "10",
},
payload: {
aps: {
alert: {
title: "Hello",
body: "World"
}
}
}
}
},
},
});
const novu = new Novu("<NOVU_API_KEY>");

novu.trigger("<WORKFLOW_TRIGGER_IDENTIFIER>", {
to: {
subscriberId: "<SUBSCRIBER_ID>",
},
payload: {
abc: "def",
},
overrides: {
fcm: {
apns: {
headers: {
"apns-priority": "10",
},
payload: {
aps: {
alert: {
title: "Hello",
body: "World"
}
}
}
}
},
},
});
(1) This setup includes APNs specific options within the FCM configuration. Make sure that your @novu/node package is up-to-date as there might be updates or fixes related to these types of configurations. If you continue to experience issues, it could be due to version mismatches or discrepancies in the TypeScript definitions. Checking the GitHub repository or updating the library might resolve these issues. If the problem persists, consider verifying against the latest official documentation or seeking further clarification from Novu's community or support channels.
ayomide
ayomide2mo ago
sorry @Ask Inkeep doing this means you will get Object literal may only specify known properties, and 'apns' does not exist in type 'ITriggerOverrideFCM'.
Ask Inkeep
Ask Inkeep2mo ago
Thanks for the follow-up, @ayomide. I'll get back to you soon. ----------------------------- While I generate an answer, here are some sources that might be helpful: * Apple Push Notification Service (APNS) * Web Component * Firebase Cloud Messaging (FCM) * Workflow Steps ----------------------------- Answer It seems like you've encountered an issue where the apns field is not recognized within the ITriggerOverrideFCM type. This indicates a possible discrepancy or limitation in the current implementation or type definitions of the Novu library. From the provided documentation and source material, specifically the Firebase Cloud Messaging (FCM) documentation from Novu (1) , there is no direct mention of support for an apns property directly within the ITriggerOverrideFCM type. This suggests that the idea of using apns directly within FCM overrides might not be supported or could be outdated. To address the issue with sending push notifications for both iOS and Android using FCM, you should focus on configuring the FCM-specific fields without trying to include APNs specific overrides directly within the FCM configuration. If APNs specific configurations are necessary for your application, it might be required to handle them separately or utilize other parts of your system designed for APNs specifically. For now, ensure your FCM configurations are correct within the supported fields, and refer to the official Novu documentation on FCM overrides for more details. If APNs configurations are a must, consider a separate handling mechanism or check for updates and clarifications in the Novu documentation or community. Here's a basic example of how you might configure FCM without the APNs override:
const novu = new Novu("<NOVU_API_KEY>");

novu.trigger("<WORKFLOW_TRIGGER_IDENTIFIER>", {
to: {
subscriberId: "<SUBSCRIBER_ID>",
},
payload: {
abc: "def",
},
overrides: {
fcm: {
// FCM-specific configurations here
priority: "high",
sound: "default"
}
},
});
const novu = new Novu("<NOVU_API_KEY>");

novu.trigger("<WORKFLOW_TRIGGER_IDENTIFIER>", {
to: {
subscriberId: "<SUBSCRIBER_ID>",
},
payload: {
abc: "def",
},
overrides: {
fcm: {
// FCM-specific configurations here
priority: "high",
sound: "default"
}
},
});
Ask Inkeep
Ask Inkeep2mo ago
Make sure to align your implementation with the latest updates from Novu's documentation. For more complex scenarios involving both FCM and APNs, consider implementing separate logic paths or seek further examples and guidance from the Novu community. : Firebase Cloud Messaging (FCM)
Ask Inkeep
Ask Inkeep5w ago
Got it. Tagging @Support for additional help.
Pawan Jain
Pawan Jain4w ago
@ayomide I see it is not added Would you like to create a PR for this?
ayomide
ayomide4w ago
Sure Any reasons why fcm tokens aren’t validated before adding them as a device token? We currently validate fcm tokens before they’re being sent to novu. It will be great if novu can handle that then I can finally remove firebase-admin package in our backend project. @Pawan Jain
Pawan Jain
Pawan Jain4w ago
@ayomide would you like to share more about validation part? how do you validate currently ?
ayomide
ayomide4w ago
Fcm has a method called dryrun which allows you to send notifications in validation mode. We use it to validate Fcm tokens, if it’s a valid fcm token or not before storing them in our database.
Pawan Jain
Pawan Jain4w ago
@ayomide Thanks for sharing. I will check out this
Want results from more Discord servers?
Add your server
More Posts