Push Notifications
Request permission, retrieve tokens, and subscribe to push notification events.
Access via appo.push.
Type Definition
Prop
Type
Usage
Request Permission
const status = await appo.push.requestPermission();
// status: 'granted' | 'denied' | 'undetermined'Get Push Token
if (status === 'granted') {
const token = await appo.push.getToken();
// token: string | null
}Subscribe to Messages
Fires when a push notification is received while the app is in the foreground. Listens on the push.message event channel.
const unsubscribe = appo.push.onMessage((message) => {
console.log(message.title, message.body, message.data);
});
// Stop listening
unsubscribe();Subscribe to Notification Taps
Fires when the user taps a notification (warm, hot, or cold start). Listens on the push.response event channel.
const unsubscribe = appo.push.onResponse((response) => {
console.log(response.title, response.body, response.actionIdentifier);
});Related Types
Prop
Type
Prop
Type
Prop
Type
Browser Fallback
| Method | Fallback |
|---|---|
requestPermission() | Returns 'denied' |
getToken() | Returns null |
onMessage() | Returns no-op unsubscribe |
onResponse() | Returns no-op unsubscribe |