-
Notifications
You must be signed in to change notification settings - Fork 1
messaging HowTo
GitHub Action edited this page Apr 21, 2026
·
1 revision
This guide covers the core operations for sending notifications.
You can register different adapters for different communication channels.
import { Messaging } from '@quatrain/messaging'
import { FirebaseMessagingAdapter } from '@quatrain/messaging-firebase'
const fcmAdapter = new FirebaseMessagingAdapter({
config: { /* Firebase credentials */ }
})
// Register the push notification adapter
Messaging.addAdapter('push', fcmAdapter)To send a message, retrieve the appropriate adapter and construct your payload. The payload structure depends on the underlying provider, but standard fields (title, body, recipient) are generally normalized.
import { Messaging } from '@quatrain/messaging'
async function notifyUser(deviceToken: string) {
const pushAdapter = Messaging.getAdapter('push')
await pushAdapter.send({
to: deviceToken,
notification: {
title: 'Your order has shipped!',
body: 'Track your package in the app.'
},
data: {
orderId: '12345'
}
})
console.log('Push notification sent.')
}