ElementsChannel

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

src/core/channel.ts
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

src/app.ts
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) required

Drivers

Driver idHow it bindsRole
fcmopenFcmChannel(…) in channel.driversFirebase Cloud Messaging HTTP v1
webpushopenWebPushChannel(…)RFC 8030 + VAPID
consoleopenConsoleChannel()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?)

OptionTypeMeaning
fromstringOptional default
senderstringAlias for from

.template(name, options?)

description · locales · schema — same as other mediums.

Troubleshooting

Learn more

Next

On this page