Search…
Notifications Module
Import
1
import notifications from 'notifications';
Copied!

Methods

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
1
// example 'after sign-in' script that notifies a list of account holders of all logins.
2
import notifications from 'notifications'
3
4
['[email protected]', '[email protected]'].forEach((recipient) => {
5
notifications.send('c_login_notify', { message: "hello there!" }, {recipient: recipient})
6
})
Copied!
Last modified 2mo ago