Push
Mobile and web push — channel.push templates, FCM device tokens, and Web Push (VAPID) drivers bound on boot.
Push (channel.push) delivers device notifications. Unlike email / SMS / WhatsApp, push
drivers are not opened by the default boot binder — pass webpush / fcm drivers on
oke({ channel: { drivers } }).
For developers notifying installed apps — FCM uses the device token as to; Web Push needs
VAPID keys on the driver.
The one rule
Declare with channel.push().template(…). Bind push drivers yourself — drivers.channel.push in
config is not auto-opened today. WhatsApp is a different medium
(WhatsApp).
Smallest Example
Declare a push template
import { channel } from "okengine";
import { z } from "zod";
const push = channel.push();
export const orderPush = push.template("order.status", {
locales: ["en"],
schema: z.object({
title: z.string(),
body: z.string(),
}),
});Bind an FCM driver
import { oke } from "okengine";
import { openFcmChannel } from "okengine/drivers";
export const app = oke({
name: "shop",
channel: {
drivers: [
openFcmChannel({
projectId: process.env.FCM_PROJECT_ID,
clientEmail: process.env.FCM_CLIENT_EMAIL,
privateKey: process.env.FCM_PRIVATE_KEY,
}),
],
catalog: {
"order.status": {
en: { subject: "{{title}}", text: "{{body}}" },
},
},
},
});FCM maps catalog subject → notification title, text → body; to is the device token.
Send
await fx.send(orderPush, {
to: deviceToken,
data: { title: "Shipped", body: "Your order is on the way." },
});Progressive Patterns
openFcmChannel requires projectId (or from) plus either service-account
clientEmail + privateKey or a pre-fetched access token / apiKey.
fcm channel: projectId (or from) is required
fcm channel: clientEmail+privateKey (service account) or token (access token) requiredDrivers
| Driver id | How it binds | Role |
|---|---|---|
fcm | openFcmChannel(…) in channel.drivers | Firebase Cloud Messaging HTTP v1 |
webpush | openWebPushChannel(…) | RFC 8030 + VAPID |
console | openConsoleChannel() | Dev inbox (all mediums) |
Config key drivers.channel.push exists for Manifest / tooling ids (console · webpush ·
fcm) but the boot binder does not open push from that map yet — pass drivers on
CreateChannelRuntimeOptions.drivers.
Options Reference
channel.push(options?)
| Option | Type | Meaning |
|---|---|---|
from | string | Optional default |
sender | string | Alias for from |
.template(name, options?)
description · locales · schema — same as other mediums.
Troubleshooting
No push driver in channel.drivers. Email/SMS/WhatsApp boot chain does not include FCM or Web
Push — add openFcmChannel / openWebPushChannel.
Open options missing project id or service-account pair / access token. See Progressive Patterns → FCM.
Web Push driver received a message without subscription keys. Supply pushSubscription on the
runtime send path; token-only to is not enough for Web Push.
Import the push binder module before oke(), or list the template under channel.templates.
Learn more
- WhatsApp — separate medium for chat
- Channel overview —
fx.sendand catalogs - Receipts — delivery ledger
- Configuration — driver id tables