-
Notifications
You must be signed in to change notification settings - Fork 7
/
web-push.html
53 lines (50 loc) · 2.4 KB
/
web-push.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<script type="text/javascript">
RED.nodes.registerType('web-push', {
category: 'PWA',
color: '#CCB2FF',
defaults: {
name: { value: "" },
vapidConfiguration: { value: "", type: "vapid-configuration", required: false }
},
inputs: 1,
outputs: 1,
icon: "pwa_icon.png",
label: function () {
return this.name || "web push";
}
});
</script>
<script type="text/x-red" data-template-name="web-push">
<div class="form-row">
<label for="node-input-vapidConfiguration"><i class="fa fa-cog"></i> Vapid Configuration</label>
<input type="text" id="node-input-vapidConfiguration">
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="web-push">
<p>Node for sending Web Push notifications using standard <a href="https://tools.ietf.org/html/draft-ietf-webpush-protocol" target="_blank">Web Push Protocol</a> and sender authentication using <a href="https://tools.ietf.org/html/draft-thomson-webpush-vapid" target="_blank">VAPID</a></p>
<p>You can use a <code>web-push-notification</code> node or you can manually set the notification properties in the <code>msg.notification</code> object.</p>
<p>For a list of supported browsers, as well as more information, take a look at the <a href="https://github.com/web-push-libs/web-push" target="_blank">web-push</a> page and also <a href="https://jakearchibald.github.io/isserviceworkerready/" target="_blank">here</a>.</p>
<p>The subscriptions must be provided in the <code>msg.subscriptions</code> object and they must contain the endpoint, as well as the p256dh and the auth keys.</p>
<p>E.g.:</p>
<pre>msg.subscriptions = [
{
endpoint: "https://fcm.googleapis.com/fcm/send/<SOME_LONG_TOKEN>",
keys: {
p256dh: "<P256DH_KEY>",
auth: "<AUTH_KEY>"
}
},
{
endpoint: "https://updates.push.services.mozilla.com/wpush/v1/<SOME_LONG_TOKEN>",
keys: {
p256dh: "<P256DH_KEY>",
auth: "<AUTH_KEY>"
}
}
]</pre>
<p>The result is returned in <code>msg.payload</code>.</p>
</script>