WebPush Notification Payload Sample
JS
S
JavaScriptNotification payload according to Google specifications. Part of web fundamentals. https://developers.google.com/web/fundamentals/push-notifications/display-a-notification
1const notificationPayload = {
2 'notification': {
3 'title': title || 'Code Recipes News!',
4 'body': message || 'New snippets have been added. Check them out!',
5 'icon': '.assets/icon-128x128.png',
6 'badge': '.assets/badge-128x128.png',
7 'vibrate': [100, 50, 100],
8 "//": "Behavioural Options",
9 "requireInteraction": false,
10 "renotify": true,
11 "silent": false,
12 'data': {
13 'dateOfArrival': Date.now(),
14 'primaryKey': 1
15 },
16 'actions': [{
17 'action': 'explore',
18 'title': 'Browse latest recipes',
19 'icon': '.assets/icon-128x128.png',
20 }]
21 }
22 };
23
24webpush.sendNotification(subscription, JSON.stringify(notificationPayload))Created on 7/6/2018