Skip to content

2. Messages and files

GianniCarlo edited this page May 17, 2016 · 3 revisions

Sending Messages

To send a message:

monkey.sendMessage(<text>, <recipient monkey id>, optionalParams, optionalPush);

  • The optionalParams is a JSON object representing extra params that the developer wants to send.
  • The optionalPush could be a String or if you want to send a localized push, then it could be a JSON object.

To send a encrypted message:

monkey.sendEncryptedMessage(<text>, <recipient monkey id>, optionalParams, optionalPush);

  • The optionalParams is a JSON object representing extra params that the developer wants to send.
  • The optionalPush could be a String or if you want to send a localized push, then it could be a JSON object.

Both these functions return a MOKMessage object (See end of document for reference)

To send a notification:

monkey.sendNotification(<recipient monkey id>, optionalParams, optionalPush);

  • The optionalParams is a JSON object representing extra params that the developer wants to send.
  • The optionalPush could be a String or if you want to send a localized push, then it could be a JSON object.

Sending Files

To send a file:

monkey.sendFile(<data>, <recipient monkey id>, <file name>, <mime type>,<file type>, <bool compressionFlag>, optionalParams, optionalPush, callback);

  • <file type> is of type MOKMessageFileType (See end of document for reference).
  • <bool compressionFlag> boolean that determines if the data should be compressed or not.
  • The optionalParams is a JSON object representing extra params that the developer wants to send.
  • The optionalPush could be a String or if you want to send a localized push, then it could be a JSON object.

To send a encrypted file:

monkey.sendEncryptedFile(<data>, <recipient monkey id>, <file name>, <mime type>, <file type>, <bool compressionFlag>, optionalParams, optionalPush, callback);

  • is of type MOKMessageFileType (See end of document for reference).
  • boolean that determines if the data should be compressed or not.
  • The optionalParams is a JSON object representing extra params that the developer wants to send.
  • The optionalPush could be a String or if you want to send a localized push, then it could be a JSON object.

Both these functions return a MOKMessage object (See end of document for reference)

Clone this wiki locally