notifications
Use local notifications for reminders and iOS remote push for server-originated updates. A notification can open a specific screen through its URL.
Declare notification permission
// kuito.config.ts
import type { KuitoConfig } from 'kuito/config';
export default {
name: 'My App',
ios: { bundleIdentifier: 'com.example.myapp' },
android: { applicationId: 'com.example.myapp' },
urlSchemes: ['myapp'],
permissions: { notifications: true },
} satisfies KuitoConfig;Schedule and cancel a reminder
import { notifications, permissions } from 'kuito';
const { status } = await permissions.request('notifications');
if (status === 'granted') {
const id = await notifications.schedule({
title: 'Stand-up',
body: 'In five minutes',
url: 'myapp://meetings/standup',
at: new Date(Date.now() + 5 * 60_000),
});
// Changed your mind:
await notifications.cancel(id);
}Configure iOS remote push
// kuito.config.ts
import type { KuitoConfig } from 'kuito/config';
export default {
name: 'My App',
android: { applicationId: 'com.example.myapp' },
urlSchemes: ['myapp'],
permissions: { notifications: true },
ios: { bundleIdentifier: 'com.example.myapp', pushEnvironment: 'development' },
} satisfies KuitoConfig;Register the device with your server
import { notifications, permissions } from 'kuito';
const { status } = await permissions.request('notifications');
if (status === 'granted') {
const { service, token } = await notifications.register();
const response = await fetch('https://example.com/devices', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ service, token }),
});
if (!response.ok) throw new Error(`Registration failed: ${response.status}`);
}Behavior and limits
Ask for permission before scheduling. at is a Date or epoch milliseconds; omit it for immediate display. A past time rejects. Keep the returned id to cancel or replace a reminder. watch("received", ...) observes foreground arrivals; it is not a background push handler. Android alarm timing depends on system permission and may be inexact. Remote push is APNs on iOS only: Android register() rejects with ERR_UNSUPPORTED. Repeating notifications, action buttons and silent background push are not implemented.
Continue
Read Permissions for the related workflow. The API reference lists every method, option, event and return type.
Reference
Exports 8
Methods, constants and types exposed by this native namespace.
scheduleShows a notification at at, or now, even when the app is in the
foreground or not running.functionwatchCalls listener with each notification that arrives while the app is in
the foreground, local or remote; it still shows.typePushTokenWhere a server sends the device's push: the service and its token.typeReceivedNotificationA notification that arrived while the app is in the foreground.typeScheduledNotificationA notification notifications.schedule shows.functioncancelTakes back the notification with this id, whether it is pending or shown.functioncancelAllTakes back every notification the app scheduled, pending or shown.functionregisterRegisters the device for remote push and resolves with the token a server
sends to.