Constructor
new WebPushClient(options)
- Source:
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | Array.<object> |
Properties
|
Example
const registration = await navigator.serviceWorker.register("/js/webpush.js", { scope: "/" });
const subscription = await registration.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: vapidKeyPublic });
app.fetch('/user/update', { data: { pushkey: "webpush://" + window.btoa(JSON.stringify(subscription)) }, type: "POST" });
Methods
send(device, options, callbackopt)
- Description:
Send web push notification to a browser
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
device |
object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
object |
Properties
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
callback |
function() |
<optional> |