Notifications Module

Import

import notifications from 'notifications';

Methods

send(name, variables, options)

send(name, variables, options)

Sends a custom notification to a single recipient.

Arguments

  • name (String) the api name of the notification template.

  • variables (Object) an object matching the variables in the matching notification handlebars template(s).

  • options

    • context (Object) optional. If specified, a notification object will be persisted and associated with the context object. If omitted, a notification object is not persisted and it will not be possible to retrieve information about the notification via the notifications endpoint, nor will it be necessary to clear the notification manually.

      • _id (ObjectId)

      • object (String)

    • locale (String:en_US)

    • recipient (ObjectId|Email:script.principal._id) A custom recipient. Defaults to the script's calling principal.

    • apiKey (String) An optional app key (eg. K0yscrO53AZqpisMmf0Nco), used to pin APNs/GCM push notifications to a single app.

    • number (String) a custom sending phone number for sms notifications. The phone number must be pre-configured in the administration interface under Settings -> Notifications.

Examples

Notifications Example

// example 'after sign-in' script that notifies a list of account holders of all logins.
import notifications from 'notifications'

['admin@myorg.com', 'developer@myorg.com'].forEach((recipient) => {
   notifications.send('c_login_notify', { message: "hello there!" }, {recipient: recipient})
})

Last updated