Scorocode.Messenger


new Messenger()

Class for message sending

Example

var broadcast = new Scorocode.Messenger();


.sendPush(options, callbacks)

Method to send Push notifications

Parameter Type Properties
options Object Message parameters
callbacks Object Success and error callbacks for the executed query.

Example

var Scorocode = require('scorocode');
Scorocode.Init({
    ApplicationID: "applicationId",
    JavaScriptKey: "javascriptKey",
    MessageKey: "messageKey"
});

var devices = new Scorocode.Query("devices");
var broadcast = new Scorocode.Messenger();
Broadcast.sendPush({
        where: devices,
        data: {
            "data": {
                "message": "PUSH text!",
                }           
            }
        })
        .then((success)=>{
            console.log(success);
        })
        .catch((error)=>{
            console.log(error)
        });

Returns: promise.{error: Boolean, count: Number} - Returns a promise, which returns the object containing the result of the query execution.

  • "error" - Boolean - Error flag
  • "count" - Number - Number of messages sent

Exception:

  • String 'Invalid options type'
  • String 'Where must be a type of Query'
  • String 'Invalid data type'
  • String 'Missing subject or text message'

.sendSms(options, callbacks)

Method to send SMS

Parameter Type Properties
options Object Message parameters
callbacks Object Success and error callbacks for the executed query.

Example

var Scorocode = require('scorocode');
Scorocode.Init({
    ApplicationID: "applicationId",
    JavaScriptKey: "javascriptKey",
    MessageKey: "messageKey"
});

var findUsers = new Scorocode.Query("users");
var broadcast = new Scorocode.Messenger();
broadcast.sendPush({
        where: findUsers,
        data: {
            "text": "SMS text"     
            }
        })
        .then((success)=>{
            console.log(success);
        })
        .catch((error)=>{
            console.log(error)
        });

Returns: {error: Boolean, count: Number} - Returns a promise, which returns the object containing the result of the query execution.

  • "error" - Boolean - Error flag
  • "count" - Number - Number of messages sent