Tech Talks

How to Enable Online Presence in Chat with MirrorFly Admin Portal?

Published On October 10th, 2022 Tech Talks

This article will walk you through the different types of online presence indicators in modern chat apps and how you can easily add them to your own apps in simple steps, to boost user engagement and retention. 

How will your app users know if the person they need to chat with is available for a conversation or not? This puzzle can be solved when you roll out online presence indicators as an in-app feature. 

Let’s get started with the integration process.

The Core Idea of this Article is to Help Developers in:

  • Understanding the basics of Online Presence Indicators
  • Types of Presence indicators
  • Step-by-step implementation of status indicators across Android, iOS, and web apps

While this might sound like a complex implementation, I bring you the good news – you can integrate these real-time status indicators within a matter of just a few minutes by using our in app chat SDK.

What is an Online Presence Indicator?

Online Presence Indicator is a messaging app feature that displays the availability and active status of other users in the form of animated icons and texts within a chat window. 

Enable Chat Online Presence

With these indicators, you will be able to know:

  1. whether a user is active on a chat app or not
  2. the last time when the user was active on the app
  3. when a user is typing a message

Next If you’d ask me what you’ll get out of this in app chat service integration, gear up! Here are the core benefits:

  • Give users the feel of life-like, in-person interactions
  • Increase the engagement rate by letting users know they got their peers active to chat with them.
  • Retains users with active conversational elements

Sounds like a good deal? So why wait while you can add them instantly to your apps?

Let’s get started with the integration process.

Step-by-Step Implementation of Online Presence Indicators

To implement Online Presence Indicators, we will use MirrorFly SDK. We will integrate the Status indicators across Android, iOS, and Web apps. 

Note: In this construct, I’ve used Java for Android apps, Swift for iOS, and Javascript for Web apps

Here’s how you will build the presence indicators:

  1. Download the SDK dependency files
  2. Import them into your chat app library
  3. Configure the SDK license into your app/build.gradle
  4. Proceed with the addition of the presence indicator elements as instructed below
 
Build an Engaging Team Chat App with Our Scalable API and SDK

Add Online Presence Indicators

Typing Status 

The below method will be used to indicate the status when other parties in a conversation are typing a message to the user in a chat window. 

ChatManager.sendTypingStatus(TO_JID, CHAT_TYPE)

Similarly when the other user has stopped or completed composing a message in the message input pane of the chat window, you need to call the below method to hide the typing status.

ChatManager.sendTypingGoneStatus(TO_JID, CHAT_TYP

Observation of the Typing Status

When the typing status changes, you need to set up the listener for the typing events. To execute this, you need to call the below method:

ChatManager.setTypingStatusListener(new TypingStatusListener() {
            @Override
            public void onChatTypingStatus(@NotNull String fromUserJid, @NotNull TypingStatus status) {
                
            }

            @Override
            public void onGroupTypingStatus(@NotNull String groupJid, @NotNull String groupUserJid, @NotNull TypingStatus status) {

            }
        });

Once the SDK sets the listener, it will trigger the callbacks based on the chat type as mentioned below:

Single chat

The below callback will be triggered for Single Chat

@Override
public void onChatTypingStatus(@NotNull String fromUserJid, @NotNull TypingStatus status) {
                
}

Group Chat

The below callback will be triggered for Group Chat 

 @Override
 public void onGroupTypingStatus(@NotNull String groupJid, @NotNull String groupUserJid, @NotNull TypingStatus status) {

 }

Last Seen Time 

To get the last seen time of the chat user, you need to call the below method:

ContactManager.getUserLastSeenTime(JID , LISTENER );

Check Last Seen Hidden Status

To check if the last seen time of a chat user is available or not, you need to call the below method:

boolean lastSeenStatus = FlyCore.isHideLastSeenEnabled();

Get Status of the Current User

The below method is used to indicate the active and inactive status in chat API configuration:

To get users’ current status, you need to use the following command:

ProfileStatus myUserStatus = FlyCore.getMyProfileStatus();

Get Busy Status of Current User

To get users the busy status, you need to use the below method:

BusyStatus myBusyStatus = FlyCore.getMyBusyStatus();

User Profile Status

To set the profile status of users, you need to call the below method:

FlyCore.setMyProfileStatus(STATUS_TEXT,(isSuccess, throwable, data) -> {
            if (isSuccess) {
               // Status Set
            } else {

            }
});

Set User Busy Status

To set the busy status for one-to-one chat conversations, you need to call the below method:

FlyCore.setMyBusyStatus(BUSY_STATUS_TEXT);

Enable or Disable Busy Status of Users

When you call the below method, your users will get to enable or disable the busy status in their chat window 

FlyCore.enableDisableBusyStatus(ENABLE_BUSY_STATUS);

Check If The Busy Status Of Users Is Enabled

Users will be able to check if the busy status is enabled or not when you call the below method

boolean isMyBusyStatusEnabled = FlyCore.isBusyStatusEnabled();

Delete User Profile Status

The Status can be deleted by users when you call the below method:

FlyCore.deleteProfileStatus(USER_STATUS);

Delete Busy Status of a User

Users will be able to delete the busy status when the below method is called

FlyCore.deleteBusyStatus(USER_BUSY_STATUS);

Android

Hide/ Show Last Seen Status 

Users will be able to hide their last seen status or show them when the below method is called:

FlyCore.enableDisableHideLastSeen( ENABLE_LAST_SEEN,(isSuccess, throwable, data) -> {

         if (isSuccess) {
            // Last seen status updated successfully
         } else {
            // updation failed print throwable for more info
         }
})

Check Last Seen Status

To enable users to check on the last seen status, the below method has to be called

boolean lastSeenStatus = FlyCore.isLastSeenEnabled();
 
Level Up Your Interactions with Our Futuristic All-in-One Chat Solution

 iOS

Enable/ Disable Last Seen Status

You need to call the below method to hide/ show the last seen status of the users. 

    ChatManager.shared.enableDisableHideLastSeen( EnableLastSeen: lastSeen) { isSuccess, flyError, flyData in
            var data  = flyData
            if isSuccess {
                print(data.getMessage() as! String )
            } else{
                print(data.getMessage() as! String )
            }
        }

Check the Last Seen Time

To check the timestamp when the user was last online, you need to call the below method:

      ChatManager.shared.getUserLastSeen( for: JID_STRING) { isSuccess, flyError, flyData in
            var data  = flyData
            if isSuccess {
                print(data.getMessage() as! String )
                print(data.getData() as! String )
            } else{
                print(data.getMessage() as! String )
            }
        }

Get The Typing Status of Users

To indicate the typing status of a user when composing a message, you need to call the below method:

GroupManager.shared.sendTyping(groupJid: "xUWD3J4oD10HcaK@mix.xmpp-preprod-abcdef.mirrorfly.com"){ isSuccess, flyError, flyData in
    if isSuccess {
    
    } else{
       
    }
}

Set Gone Status

To stop indicating the typing status of the user, when he/ she has stopped composing a message in the input window of the chat window, you need to call the below method:

GroupManager.shared.sendTypingGone(groupJid: "xUWD3J4oD10HcaK@mix.xmpp-preprod-abcdef.mirrorfly.com"){ isSuccess, flyError, flyData in
    if isSuccess {
    
    } else{
       
    }
}

Web

To get the last seen time of the users in a web chat conversation, you need to call the below method:

await SDK.getLastSeen(`TO_USER_JID`);

Conclusion:

There you have it! You have successfully integrated online presence in the admin portal of your your Android chat app using MirrorFly SDKs. Your users will now be able to see typing status and Last seen time in their chat interfaces.

So what’s next?

MirrorFly’s Chat APIs & SDKs just don’t stop with presence indicators. Here are some of the best resources you can add to your video chat app to build modern conversations:

In my next guide, I will walk you through the steps in implementing push notifications in your Chat apps. If you are interested to learn further, post in a comment below of what other in-app chat topics should I write next on. Until then, I wish you the best in building your chat app!

 

Vigneshwar

Vigneshwar is a seasoned digital marketer and blogger, extremely passionate about driving search engine visibility for websites. He thoroughly enjoys exploring emerging technologies and is currently honing his expertise in Chat APIs and their associated tech stacks.

This article will walk you through the different types of online presence indicators in modern chat apps and how you can easily add them to your own apps in simple steps, to boost user engagement and retention. 

How will your app users know if the person they need to chat with is available for a conversation or not? This puzzle can be solved when you roll out online presence indicators as an in-app feature. 

Let’s get started with the integration process.

The Core Idea of this Article is to Help Developers in:

  • Understanding the basics of Online Presence Indicators
  • Types of Presence indicators
  • Step-by-step implementation of status indicators across Android, iOS, and web apps

While this might sound like a complex implementation, I bring you the good news – you can integrate these real-time status indicators within a matter of just a few minutes by using our in app chat SDK.

What is an Online Presence Indicator?

Online Presence Indicator is a messaging app feature that displays the availability and active status of other users in the form of animated icons and texts within a chat window. 

Enable Chat Online Presence

With these indicators, you will be able to know:

  1. whether a user is active on a chat app or not
  2. the last time when the user was active on the app
  3. when a user is typing a message

Next If you’d ask me what you’ll get out of this in app chat service integration, gear up! Here are the core benefits:

  • Give users the feel of life-like, in-person interactions
  • Increase the engagement rate by letting users know they got their peers active to chat with them.
  • Retains users with active conversational elements

Sounds like a good deal? So why wait while you can add them instantly to your apps?

Let’s get started with the integration process.

Step-by-Step Implementation of Online Presence Indicators

To implement Online Presence Indicators, we will use MirrorFly SDK. We will integrate the Status indicators across Android, iOS, and Web apps. 

Note: In this construct, I’ve used Java for Android apps, Swift for iOS, and Javascript for Web apps

Here’s how you will build the presence indicators:

  1. Download the SDK dependency files
  2. Import them into your chat app library
  3. Configure the SDK license into your app/build.gradle
  4. Proceed with the addition of the presence indicator elements as instructed below
 
Build an Engaging Team Chat App with Our Scalable API and SDK

Add Online Presence Indicators

Typing Status 

The below method will be used to indicate the status when other parties in a conversation are typing a message to the user in a chat window. 

ChatManager.sendTypingStatus(TO_JID, CHAT_TYPE)

Similarly when the other user has stopped or completed composing a message in the message input pane of the chat window, you need to call the below method to hide the typing status.

ChatManager.sendTypingGoneStatus(TO_JID, CHAT_TYP

Observation of the Typing Status

When the typing status changes, you need to set up the listener for the typing events. To execute this, you need to call the below method:

ChatManager.setTypingStatusListener(new TypingStatusListener() {
            @Override
            public void onChatTypingStatus(@NotNull String fromUserJid, @NotNull TypingStatus status) {
                
            }

            @Override
            public void onGroupTypingStatus(@NotNull String groupJid, @NotNull String groupUserJid, @NotNull TypingStatus status) {

            }
        });

Once the SDK sets the listener, it will trigger the callbacks based on the chat type as mentioned below:

Single chat

The below callback will be triggered for Single Chat

@Override
public void onChatTypingStatus(@NotNull String fromUserJid, @NotNull TypingStatus status) {
                
}

Group Chat

The below callback will be triggered for Group Chat 

 @Override
 public void onGroupTypingStatus(@NotNull String groupJid, @NotNull String groupUserJid, @NotNull TypingStatus status) {

 }

Last Seen Time 

To get the last seen time of the chat user, you need to call the below method:

ContactManager.getUserLastSeenTime(JID , LISTENER );

Check Last Seen Hidden Status

To check if the last seen time of a chat user is available or not, you need to call the below method:

boolean lastSeenStatus = FlyCore.isHideLastSeenEnabled();

Get Status of the Current User

The below method is used to indicate the active and inactive status in chat API configuration:

To get users’ current status, you need to use the following command:

ProfileStatus myUserStatus = FlyCore.getMyProfileStatus();

Get Busy Status of Current User

To get users the busy status, you need to use the below method:

BusyStatus myBusyStatus = FlyCore.getMyBusyStatus();

User Profile Status

To set the profile status of users, you need to call the below method:

FlyCore.setMyProfileStatus(STATUS_TEXT,(isSuccess, throwable, data) -> {
            if (isSuccess) {
               // Status Set
            } else {

            }
});

Set User Busy Status

To set the busy status for one-to-one chat conversations, you need to call the below method:

FlyCore.setMyBusyStatus(BUSY_STATUS_TEXT);

Enable or Disable Busy Status of Users

When you call the below method, your users will get to enable or disable the busy status in their chat window 

FlyCore.enableDisableBusyStatus(ENABLE_BUSY_STATUS);

Check If The Busy Status Of Users Is Enabled

Users will be able to check if the busy status is enabled or not when you call the below method

boolean isMyBusyStatusEnabled = FlyCore.isBusyStatusEnabled();

Delete User Profile Status

The Status can be deleted by users when you call the below method:

FlyCore.deleteProfileStatus(USER_STATUS);

Delete Busy Status of a User

Users will be able to delete the busy status when the below method is called

FlyCore.deleteBusyStatus(USER_BUSY_STATUS);

Android

Hide/ Show Last Seen Status 

Users will be able to hide their last seen status or show them when the below method is called:

FlyCore.enableDisableHideLastSeen( ENABLE_LAST_SEEN,(isSuccess, throwable, data) -> {

         if (isSuccess) {
            // Last seen status updated successfully
         } else {
            // updation failed print throwable for more info
         }
})

Check Last Seen Status

To enable users to check on the last seen status, the below method has to be called

boolean lastSeenStatus = FlyCore.isLastSeenEnabled();
 
Level Up Your Interactions with Our Futuristic All-in-One Chat Solution

 iOS

Enable/ Disable Last Seen Status

You need to call the below method to hide/ show the last seen status of the users. 

    ChatManager.shared.enableDisableHideLastSeen( EnableLastSeen: lastSeen) { isSuccess, flyError, flyData in
            var data  = flyData
            if isSuccess {
                print(data.getMessage() as! String )
            } else{
                print(data.getMessage() as! String )
            }
        }

Check the Last Seen Time

To check the timestamp when the user was last online, you need to call the below method:

      ChatManager.shared.getUserLastSeen( for: JID_STRING) { isSuccess, flyError, flyData in
            var data  = flyData
            if isSuccess {
                print(data.getMessage() as! String )
                print(data.getData() as! String )
            } else{
                print(data.getMessage() as! String )
            }
        }

Get The Typing Status of Users

To indicate the typing status of a user when composing a message, you need to call the below method:

GroupManager.shared.sendTyping(groupJid: "xUWD3J4oD10HcaK@mix.xmpp-preprod-abcdef.mirrorfly.com"){ isSuccess, flyError, flyData in
    if isSuccess {
    
    } else{
       
    }
}

Set Gone Status

To stop indicating the typing status of the user, when he/ she has stopped composing a message in the input window of the chat window, you need to call the below method:

GroupManager.shared.sendTypingGone(groupJid: "xUWD3J4oD10HcaK@mix.xmpp-preprod-abcdef.mirrorfly.com"){ isSuccess, flyError, flyData in
    if isSuccess {
    
    } else{
       
    }
}

Web

To get the last seen time of the users in a web chat conversation, you need to call the below method:

await SDK.getLastSeen(`TO_USER_JID`);

Conclusion:

There you have it! You have successfully integrated online presence in the admin portal of your your Android chat app using MirrorFly SDKs. Your users will now be able to see typing status and Last seen time in their chat interfaces.

So what’s next?

MirrorFly’s Chat APIs & SDKs just don’t stop with presence indicators. Here are some of the best resources you can add to your video chat app to build modern conversations:

In my next guide, I will walk you through the steps in implementing push notifications in your Chat apps. If you are interested to learn further, post in a comment below of what other in-app chat topics should I write next on. Until then, I wish you the best in building your chat app!

 

Vigneshwar

Vigneshwar is a seasoned digital marketer and blogger, extremely passionate about driving search engine visibility for websites. He thoroughly enjoys exploring emerging technologies and is currently honing his expertise in Chat APIs and their associated tech stacks.

3 Comments "How to Enable Online Presence in Chat with MirrorFly Admin Portal?"

  1. Harper says:

    Hi I’m Harper, I’d like to call an endpoint to get the last seen time of my app users and it seems like a challenge to me. Any suggestions?

  2. Felicia H says:

    Hello there!
    I’m trying to fetch the online status of my iOS app users. Is it possible with your APIs? – Felicia Hoyles

    1. Vigneshwar says:

      Hi Ms. Hoyles, Glad to know that you are building a chat app. Yes, our APIs will let you indicate user presence across all platforms. Whether your users have an android, iOS, or web app, they will be able to find the presence status, last seen time, and read receipts within a contact profile. If you’d like to integrate this feature, our experts are ready to support you. Best wishes to you!

Leave a Reply

Your email address will not be published.