Not able to handle primaray/secondary actions through cdn embed.
I am only able to run this piece of code with iframe. I want to use this with the cdn embed. Please help me how can I do that, not able to find on docs
novu.on("action_click", ({ templateIdentifier, type, notification }) => {
console.log({ templateIdentifier, type, notification });
window.alert("Yes! this worked!")
});
8 Replies
Hi @ManwinderSingh, I'm an AI assistant for Novu. While a team member reviews this question, I'll look through relevant sources and see if I can provide suggestions. Please tag @Ask Inkeep with any follow-up questions.
-----------------------------
While I generate an answer, here are some sources that might be helpful:
* Iframe Embed
* React
* Web Component
* Angular Component
-----------------------------
Answer
To use the
novu.on("action_click", ...)
functionality with the CDN embed rather than the iFrame embed, you can follow the instructions provided for the Web Component integration. The Web Component allows you to listen to user interactions, including action clicks, similarly to what you've described.
First, ensure you've included the Novu Notification Center Web Component by adding its script tag to your HTML:
(1)
Then, instantiate the Novu Notification Center component in your application, setting up the onActionClick
callback to handle action clicks:
Make sure to replace "YOUR_APPLICATION_IDENTIFIER"
and "YOUR_SUBSCRIBER_ID"
with your actual application identifier and subscriber ID. The event names are in kebab-case (e.g., on-action-click
) when used as attributes in the HTML tag for the component.
This setup allows you to capture and handle action clicks on notifications when using the Novu Notification Center as a Web Component, leveraging its CDN embed.Still getting this
Got it. Tagging @Support for additional help.
@Emil please take a look at this. Need help here
cc @Pawan Jain @Moderator
@ManwinderSingh checking this in web component
@ManwinderSingh
checkout
nc.onActionClick
method in this codesandbox
https://codesandbox.io/p/sandbox/novu-web-component-bundled-rgrj5r?file=%2Findex.js%3A48%2C1-52%2C1Thanks @Pawan Jain It helped