# Unread Message

When the customer service replies user's message, user can receive a notification of unread messages, even if the AIHelp page is not currently displayed.

You can implement this function either by proactively fetching or by third-party push.

WARNING

By default, AIHelp uses a randomly generated deviceId as userId to poll for the count of unread messages.

So, until you sync the correct userId to AIHelp, the unread message count may be inaccurate.

# By Fetching

# API

# FetchUnreadMessageCount()

Calling this method allows you to actively retrieve the unread message count for the current user.

AIHelpSupport.FetchUnreadMessageCount();

You can call this API at any time to query the unread message count for the current user, but please note:

  1. This method has a 5-minute frequency limit:

Repeated calls within the limit period will return the result of the previous query. During development, you can check the logs to see the time until the next valid call.

  1. This method will return 0 in the following situations to notify the caller that the current user has no unread messages:
  • When the user has no ongoing complaints.
  • When the user is on an AIHelp page.
  • When the user opens the customer service conversation window.

# Event

Subscribe to the MessageArrival event to receive notifications about unread message changes for the current user.

AIHelpSupport.RegisterAsyncEventListener(AIHelp.EventType.MessageArrival, 
    (jsonEventData, ignored) => {
        // `jsonEventData`: { "msgCount": 1 }
    }
);

# By Third-Party Push

Please refer to Android or iOS documentation for more information.

Last Updated: 7/15/2024, 10:53:10 AM