Messaging Services for Mobile Apps

by February 15, 2018

The Mobile App Services (MAS) Messaging service lets you create collaborative mobile apps where the app users can send message to each other. The MAS Messaging SDK uses MQTT protocol, a publish- subscribe based message protocol to send and receive messages. App users can subscribe, publish, and listen to the messages based on the topic of the messages. Our MAG has the broker installed to facilitates the publishing and subscribing of messages. You can accomplish the messaging tasks by using the following MAS Messaging methods:

  • Connect – Establishes a connection with the server.
  • Subscribe – Subscribes a user to a topic
  • Unsubscribe – Unsubscribes a user from a topic.
  • Publish – Publishes a message to a topic.
  • Disconnect – Disconnects from the server.

Now let us get started with the MAS Messaging by downloading the MAS Messaging plugin from our Cordova repository. Now to add the MAS Messaging plugin to your project, follow these steps:

1.      Open a terminal window.

2.      Run the following command to add the plugin to your project:

3.      Call the following method to listen to a message that is received on your topic (i.e.your username):

4.      Call the following method to register a listener that is called every time you receive a message:

5.      Call the following method to send message to a user:

You’re all set to send and receive messages on your app.

We now have a complete messaging app ready. For further details, head over to our documentation.