push

Description:
  • Messaging and push notifications for mobile and other clients, supports Webpush push notifications.

    Emits a signal uninstall(client, device_id, user_id) on device invalidation or if a device token is invalid as reported by the server, user_id may not be available.

Source:

Classes

APNClient
FCMClient
SNSClient
WebpushClient

Methods

(static) configureModule(options)

Description:
  • Perform initial setup by calling static configure method for each module

Source:
Parameters:
Name Type Description
options object | Array.<object>

whole config object for the type

(static) init(options, callbackopt)

Description:
  • Initialize supported notification services, it supports jobs arguments convention so can be used in the jobs that need to send push notifications in the worker process. Can be called muny times, only new modules will be initialized.

Source:
Parameters:
Name Type Attributes Description
options object
callback function <optional>

(static) parseDevice(device)

Description:
  • Parse device URN and returns an object with all parts into separate properties. A device URN can be in the following format:

Source:
Parameters:
Name Type Description
device string

[type://]token[@app]

  • type - apn, fcm, webpush, sns, ...
  • token - device token
  • app - optional application name or bundle

(static) send(device, options, callback)

Description:
  • Deliver a notification for the given device token(s).

Source:
Parameters:
Name Type Description
device string

where to send the message to, can be multiple ids separated by , or |.

options object
Properties
Name Type Description
user_id string

an user id associated with this token, for debugging and invalid token management

app_id string

send to the devices for the given app only

msg string

text message to send

badge int

badge number to show if supported by the service

sound boolean

set to true if a sound should be produced on message receive

type string

set type of the message, service specific

category string

action category for APN

id string

send id with the notification, this is application specific data, sent as is

name string

notification group name, can be used for grouping multiple messages under this name

url string

a launch url for the app, it show associated screen on launch if supported

callback function

(static) shutdown(options, callbackopt)

Description:
  • Shutdown notification services, may wait till all pending messages are sent before calling the callback

Source:
Parameters:
Name Type Attributes Description
options object
callback function <optional>