Messaging Services for Mobile Apps

Sangharsh Aglave, Software Engineer

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:

ionic plugin add PATH_TO_PLUGIN

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

MASConnectaPlugin.MASUser.startListeningToMyMessages(successHandler, errorHandler);

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

MASConnectaPlugin.MASRegisterListener(successHandler, errorHandler);

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

MASConnectaPlugin.MASUser.sendMessageToUser(successHandler, errorHandler, message, username);

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.

Sangharsh Aglave, Software Engineer, CA Technologies

Sangharsh Aglave is a Software Engineer at CA Technologies. He works in the API Management Business Unit where he works on mobile technologies on the Mobile App Services product.

Sangharsh graduated from the Computer Science Department at Indian Institute of Technology, Kanpur in 2015. He worked as a summer intern at CA and consequently joined CA as a college recruit after graduation. He has a keen interest in mobile technologies and has worked on both iOS and Android platforms. He also likes to explore emerging fields in Computer Science like machine learning and artificial intelligence.

What would you like to chat about?
Call us at +1-800-225-5224
Call us at +1-800-225-5224
Contact Us