- ServiceWorker
Service Workers
- Notification
Notifications
- Push
Push Manager
- Navigator
Navigator
- Server
Server
- Helper
Helpers
- PWA
Global const.
Service Workers
Kind: global class
- ServiceWorker
- .register() ⇒
undefined
- .getRegistration(callback) ⇒
Object
- .register() ⇒
Register principal Service Worker
Kind: static method of ServiceWorker
Get registered Service Worker
Kind: static method of ServiceWorker
Returns: Object
- registration object
Param | Type | Description |
---|---|---|
callback | function | Return callback with registration object. |
Notifications
Kind: global class
- Notification
- .show(title, options, callback) ⇒
Boolean
- .isDefault() ⇒
Boolean
- .isGranted() ⇒
Boolean
- .isBlocked() ⇒
Boolean
- .isDenied() ⇒
Boolean
- .requestPermission(callback) ⇒
String
- .getPermission() ⇒
String
|null
- .show(title, options, callback) ⇒
Show notification
Kind: static method of Notification
Param | Type | Description |
---|---|---|
title | String | Notification title. |
options | Object | Options of navigator.serviceWorker.registration.showNotification(). |
callback | function | Return callback with boolean |
Notifications permission with default status
Kind: static method of Notification
Returns: Boolean
- Return true if is default status.
Notifications permission was granted
Kind: static method of Notification
Returns: Boolean
- Return true if is granted.
Notifications permission was blocked
Kind: static method of Notification
Returns: Boolean
- Return true if is blocked
Notifications are denied
Kind: static method of Notification
Returns: Boolean
- Return true if is denied
Displays a pop-up message from the browser requesting permission to allow notifications.
Kind: static method of Notification
Param | Type | Description |
---|---|---|
callback | function | Return callback with status string. |
Get notifications permission
Kind: static method of Notification
Returns: String
| null
- Return string ('granted'|'blocked'|'denied') or null.
Push Manager
Kind: global class
- Push
- .subscribe(callback) ⇒
Object
- .unsubscribe(callback) ⇒
Boolean
- .updateSubscription(callback) ⇒
Boolean
- .getSubscription(callback) ⇒
Object
|null
- .subscribe(callback) ⇒
Subscribe to Push and send to Server API
Kind: static method of Push
Returns: Object
- subscription
Param | Type | Description |
---|---|---|
callback | function | Return callback with subscription object. |
Unsubscribe to Push and send to Server API
Kind: static method of Push
Param | Type | Description |
---|---|---|
callback | function | Return callback with boolean |
Update the subscription to Push and send to Server API
Kind: static method of Push
Param | Type | Description |
---|---|---|
callback | function | Return callback with boolean |
Get subscription object
Kind: static method of Push
Param | Type | Description |
---|---|---|
callback | function | Return callback with subscription object or null. |
Navigator
Kind: global class
- Navigator
- .isSupportedServiceWorker() ⇒
Boolean
- .isSupportedNotification() ⇒
Boolean
- .isOffline() ⇒
Boolean
- .clearCache() ⇒
undefined
- .isSupportedServiceWorker() ⇒
Navigator support Service Workers
Kind: static method of Navigator
Navigator support Notifications
Kind: static method of Navigator
Navigator is offline
Kind: static method of Navigator
Clear Cache of Navigator
Kind: static method of Navigator
Server
Kind: global class
- Server
- .send(endpoint, method, body) ⇒
Object
- .sendSubscription(subscription, method) ⇒
Object
- .send(endpoint, method, body) ⇒
Send data to API Server
Kind: static method of Server
Returns: Object
- Return Promise object
Param | Type | Description |
---|---|---|
endpoint | String | URL of endpoint of server API |
method | String | ('GET'|'POST'|'PUT'|'DELETE') |
body | ArrayBuffer | ArrayBufferView | Blob | File | String | URLSearchParams | FormData |
Send subscription data to API Server
Kind: static method of Server
Returns: Object
- Return Promise object
Param | Type | Description |
---|---|---|
subscription | Object | Subscription object |
method | String | ('POST'|'PUT'|'DELETE') |
Helpers
Covert urlBase64 To Uint8Array
Kind: static method of Helper
Returns: Uint8Array
- Uint8Array
Param | Type | Description |
---|---|---|
base64String | String | base64 string |
Kind: global constant
Version: 0.1
Author: Jordi Fernandes Alves jfadev@gmail.com
Param | Type | Description |
---|---|---|
PWA_CONFIG | Object | PWA global configs |
notification | Object | Notification native class. |