Notifications

Notifications may be sent from a script.

Sending

import notifications from 'notifications'

Define custom endpoints:

return notifications.send('c_axon_leave_study', {
  var1: 'test1',
  var2: 'test2'
}, {
  endpoints: {
    push: {
      template: 'message as template {{var1}}',
      apn: {
        topics: [
          'app',
          'voip'
        ]
      }
    }
  }
})

Define custom HTML:

Send a predefined notification:

Send an empty notification:

Send a notification without a template or that is not predefined:

Send a Short Message Service (SMS) request to a custom mobile number using an existing template:

Send an SMS to a custom mobile number without a template:

Send an SMS to a custom mobile number without a template (example 2):

Send an SMS to a recipient without a template:

Push a mobile notification to a recipient using an existing template:

Push a mobile notification to a recipient using an existing template:

Send an email using an existing template:

Send an email with HTML and no template:

Send an email with a plain message and no template:

Legacy

send(name, variables, options)

Arguments

  • name { String } Notification name

  • variables { Object } Variables to be used in templates

  • options { Object } [Optional]

    • number { String } Sender number

    • recipient { ObjectID, String } ObjectID from account or email

    • context { Object }

    • locale { String } For example, 'en_US'

    • apiKey { String }

    • count { Number } If set, sets the badge on the device icon

    • sound { String } If provided, overrides the default sound

    • apnTopics { String [] }

    • fcmTopic { String [] }

    • pushType { String } Applies only for Apple Push Notification (APN)

send(payload, options)

Arguments

  • payload { Object | String | Number } In case of string, used as payload only; if not, starts with c_ or __ or not in system notification names

  • options { Object } [Optional]

    • context { Object }

    • locale { String } For example, 'en_US'

    • apiKey { String }

    • endpoints { Object }

      • email { Object }

        • recipient { ObjectID | String } ObjectID from account or email

        • template { String }

        • message { String } Plain text message

        • html { String } HTML message

      • push { Object }

        • template { String }

        • message { String }

          • apn { Object }

            • topics { String [] }

            • pushType { String }

          • fcm { Object }

            • topic { String }

          • tpns { Object }

      • sms { Object }

        • mobile { String } Recipient phone number

        • number { String } Sender number

        • message { String }

View Tencent Push Notification Service (TPNS) for more information about Tencent API push notifications.

Last updated

Was this helpful?