Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

401 lines (320 sloc) 10.9 KB

API Reference

Classes

ServiceWorker

Service Workers

Notification

Notifications

Push

Push Manager

Navigator

Navigator

Server

Server

Helper

Helpers

Constants

PWA

Global const.

ServiceWorker

Service Workers

Kind: global class

ServiceWorker.register() ⇒ undefined

Register principal Service Worker

Kind: static method of ServiceWorker

ServiceWorker.getRegistration(callback) ⇒ Object

Get registered Service Worker

Kind: static method of ServiceWorker
Returns: Object - registration object

ParamTypeDescription
callbackfunction

Return callback with registration object.

Notification

Notifications

Kind: global class

Notification.show(title, options, callback) ⇒ Boolean

Show notification

Kind: static method of Notification

ParamTypeDescription
titleString

Notification title.

optionsObject

Options of navigator.serviceWorker.registration.showNotification().

callbackfunction

Return callback with boolean

Notification.isDefault() ⇒ Boolean

Notifications permission with default status

Kind: static method of Notification
Returns: Boolean - Return true if is default status.

Notification.isGranted() ⇒ Boolean

Notifications permission was granted

Kind: static method of Notification
Returns: Boolean - Return true if is granted.

Notification.isBlocked() ⇒ Boolean

Notifications permission was blocked

Kind: static method of Notification
Returns: Boolean - Return true if is blocked

Notification.isDenied() ⇒ Boolean

Notifications are denied

Kind: static method of Notification
Returns: Boolean - Return true if is denied

Notification.requestPermission(callback) ⇒ String

Displays a pop-up message from the browser requesting permission to allow notifications.

Kind: static method of Notification

ParamTypeDescription
callbackfunction

Return callback with status string.

Notification.getPermission() ⇒ String | null

Get notifications permission

Kind: static method of Notification
Returns: String | null - Return string ('granted'|'blocked'|'denied') or null.

Push

Push Manager

Kind: global class

Push.subscribe(callback) ⇒ Object

Subscribe to Push and send to Server API

Kind: static method of Push
Returns: Object - subscription

ParamTypeDescription
callbackfunction

Return callback with subscription object.

Push.unsubscribe(callback) ⇒ Boolean

Unsubscribe to Push and send to Server API

Kind: static method of Push

ParamTypeDescription
callbackfunction

Return callback with boolean

Push.updateSubscription(callback) ⇒ Boolean

Update the subscription to Push and send to Server API

Kind: static method of Push

ParamTypeDescription
callbackfunction

Return callback with boolean

Push.getSubscription(callback) ⇒ Object | null

Get subscription object

Kind: static method of Push

ParamTypeDescription
callbackfunction

Return callback with subscription object or null.

Navigator

Navigator

Kind: global class

Navigator.isSupportedServiceWorker() ⇒ Boolean

Navigator support Service Workers

Kind: static method of Navigator

Navigator.isSupportedNotification() ⇒ Boolean

Navigator support Notifications

Kind: static method of Navigator

Navigator.isOffline() ⇒ Boolean

Navigator is offline

Kind: static method of Navigator

Navigator.clearCache() ⇒ undefined

Clear Cache of Navigator

Kind: static method of Navigator

Server

Server

Kind: global class

Server.send(endpoint, method, body) ⇒ Object

Send data to API Server

Kind: static method of Server
Returns: Object - Return Promise object

ParamTypeDescription
endpointString

URL of endpoint of server API

methodString

('GET'|'POST'|'PUT'|'DELETE')

bodyArrayBuffer | ArrayBufferView | Blob | File | String | URLSearchParams | FormData

Server.sendSubscription(subscription, method) ⇒ Object

Send subscription data to API Server

Kind: static method of Server
Returns: Object - Return Promise object

ParamTypeDescription
subscriptionObject

Subscription object

methodString

('POST'|'PUT'|'DELETE')

Helper

Helpers

Kind: global class

Helper.urlBase64ToUint8Array(base64String) ⇒ Uint8Array

Covert urlBase64 To Uint8Array

Kind: static method of Helper
Returns: Uint8Array - Uint8Array

ParamTypeDescription
base64StringString

base64 string

PWA

Kind: global constant
Version: 0.1
Author: Jordi Fernandes Alves jfadev@gmail.com

ParamTypeDescription
PWA_CONFIGObject

PWA global configs

notificationObject

Notification native class.

You can’t perform that action at this time.