Send push notification but without trigger browser notification
I understand that when I trigger a workflow, it will trigger browser to display a notification. But I want to do different with workflow, I want like in-app, where user click at that notification, it will redirect user to my site instead of disappear when click on notification.
I tried already with small scripts but doesn't work:
I tried already with small scripts but doesn't work:
const payload = {
characterName: 'Emma',
characterImage: 'https://imagedelivery.net/your-account/character-emma/public',
message: 'Hey! I miss chatting with you... π',
unreadCount: 3,
ctaUrl: 'https://bonza.chat/chat/emma',
// Add title/body for Novu workflow template variables
title: 'Emma sent you a message π',
body: 'Hey! I miss chatting with you... π'
};
await novu.trigger({
workflowId: "test",
to: [
{
type: 'Topic',
topicKey: TOPIC_ID,
channels: [
{ ProviderId: 'fcm' }
]
}],
payload,
overrides: {
fcm: {
// Send data-only message (no notification field)
// This ensures ONLY the service worker handles the notification
data: {
title: String(payload.title),
body: String(payload.body),
characterName: String(payload.characterName),
characterImage: String(payload.characterImage),
message: String(payload.message),
unreadCount: String(payload.unreadCount),
ctaUrl: String(payload.ctaUrl)
}
}
}
}).then((response) => {
console.log('β
Notification triggered successfully:', response);
console.log('π¦ Payload sent:', payload);
}).catch((error) => {
console.error('β Failed to trigger notification:', error);
});const payload = {
characterName: 'Emma',
characterImage: 'https://imagedelivery.net/your-account/character-emma/public',
message: 'Hey! I miss chatting with you... π',
unreadCount: 3,
ctaUrl: 'https://bonza.chat/chat/emma',
// Add title/body for Novu workflow template variables
title: 'Emma sent you a message π',
body: 'Hey! I miss chatting with you... π'
};
await novu.trigger({
workflowId: "test",
to: [
{
type: 'Topic',
topicKey: TOPIC_ID,
channels: [
{ ProviderId: 'fcm' }
]
}],
payload,
overrides: {
fcm: {
// Send data-only message (no notification field)
// This ensures ONLY the service worker handles the notification
data: {
title: String(payload.title),
body: String(payload.body),
characterName: String(payload.characterName),
characterImage: String(payload.characterImage),
message: String(payload.message),
unreadCount: String(payload.unreadCount),
ctaUrl: String(payload.ctaUrl)
}
}
}
}).then((response) => {
console.log('β
Notification triggered successfully:', response);
console.log('π¦ Payload sent:', payload);
}).catch((error) => {
console.error('β Failed to trigger notification:', error);
});