Platform publish formats
Each platform supports different options when publishing notifications via the publishToUsers
and publishToInterests
methods. These are the formats expected by each platform.
∞ FCM format
The full set of options is described by Google in their documentation of FCM downstream HTTP messages
publishToUsers(["SOME_USER"], {
fcm: {
notification: {
title: "You have a new message",
body: "Hi!",
},
data: {
some: "metadata",
of: "your",
choosing: "can",
go: "here 😏",
},
},
});
∞ APNs format
The full set of options for the APNs section of the notify
call is described in Apple’s Payload Key Reference. For further examples, see Apple’s “Creating the Remote Notification Payload”
publishToUsers(["SOME_USER"], {
apns: {
alert: {
title: "You have a new message",
body: "Hi!",
},
data: {
some: "metadata",
of: "your",
choosing: "can",
go: "here 😏",
},
},
});
∞ Web format
Pusher Beams offers a bespoke format for sending web notifications that works across all supported browsers.
- ∞ time_to_liveInteger Optional
-
The number of seconds the web push gateway should store the notification for whilst the user is offline. Max: 2419200; Default: 4 weeks.
- ∞ notificationObject Optional
- ∞ dataObject Optional
-
Arbitrary object containing any custom metadata you would like to send with the notification. Cannot contain the key “pusher”.
∞ Notification object format
- ∞ titleString Optional
-
The title shown when the notification is displayed to the user.
- ∞ bodyString Optional
-
The body shown when the notification is displayed to the user.
- ∞ iconString Optional
-
URL of the image shown as the notification icon when the notification is displayed.
- ∞ deep_linkString Optional
-
If provided, this URL will be opened in a new tab when the notification is clicked.
- ∞ hide_notification_if_site_has_focusBoolean Optional
-
If set to true, the notification will not be shown if your site has focus. Default: false.
publishToUsers(["SOME_USER"], {
web: {
time_to_live: 3600,
notification: {
title: "You have a new message",
body: "Hi!",
icon: "https://example.com/img/notification-icon.png",
deep_link: "https://example.com/messages?message_id=2342",
hide_notification_if_site_has_focus: true,
},
data: {
some: "metadata",
of: "your",
choosing: "can",
go: "here 😏",
},
},
});