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

APNPushClient
FCMPushClient
SNSPushClient
WebPushClient

Members

(inner, constant) args

Source:
Default Value:
  • [
      {
        "name": "config",
        "obj": "_config",
        "type": "json",
        "merge": 1,
        "descr": "An object with client configs by type",
        "example": "-push-config {\"webpush\":{\"type\":\"webpush\",key\":XXX\",\"pubkey\":\"XXXX\"}}"
      },
      {
        "name": "([a-z0-9]+)",
        "obj": "_config.$1",
        "type": "map",
        "merge": 1,
        "descr": "A single client type parameters",
        "example": "-push-webpush type:webpush,key:K,pubkey:PK,email:XXX"
      }
    ]
Properties:
Type Description
Array.<ConfigOptions>

Methods

(async, static) asend(device, options) → {Promise}

Description:
Source:
Parameters:
Name Type Description
device string

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

options object
Returns:
Type Description
Promise

as object { err }

(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 many 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

see each driver for specific properties, module:push.WebPushClient, module:push.APNPushClient, module:push.FCMPushClient, module:push.SNSPushClient,

Properties
Name Type Attributes Description
msg string

message body

title string <optional>

message title

app_id string <optional>

send to the devices for the given app only

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>