Genesys Cloud - Developer Community!

 View Only

Sign Up

iOS Mobile Messenger: Request for SDK-provided unread message count API (GenesysCloud SDK 1.21.0)

  • 1.  iOS Mobile Messenger: Request for SDK-provided unread message count API (GenesysCloud SDK 1.21.0)

    Posted an hour ago

    Hey! We are integrating the iOS Mobile Messenger GenesysCloud SDK via SPM:

    https://github.com/MyPureCloud/mobile-messenger-genesyscloud-spm

    Current version: `1.21.0`

    ## Use case

    We show a custom minimized chat bubble in our iOS app. When the user has an active Genesys Messenger conversation and minimizes the chat, we need to show the number of unread support messages on that bubble.

    The problematic flow is:

    1. User opens Genesys chat.
    2. User minimizes the chat.
    3. User backgrounds the app.
    4. Agent sends one or more new messages while the app is backgrounded.
    5. User reopens the app before the APNS push notification is delivered.

    In this window, push delivery can lag by roughly 40 seconds. Because the push has not arrived yet, our local unread badge can still show `0`, even though the conversation already contains unread agent messages.

    ## What we are doing today

    We are using `ChatController` and delegates.

    To work around the delayed push window, we are trying to reconcile unread state ourselves when the app returns to foreground:

    - request/recover chat history on foreground,
    - inspect recovered `ChatElement`s,
    - track the latest seen agent message,
    - persist lightweight state across minimize/background/startup,
    - avoid counting messages already visible while chat was open,
    - deduplicate SDK history replay and later live callbacks,
    - keep unread at `0` while the chat UI is presented.

    This works, but it adds a lot of app-side state and edge-case handling for something that feels like it would be safer if owned by the SDK/runtime.

    ## Feature request

    Is there, or could there be, a supported SDK API for retrieving the authoritative unread message count for the current Messenger conversation?

    For example, something like:

    - `ChatController.unreadMessageCount`
    - `ChatController.fetchUnreadMessageCount(...)`
    - a delegate callback such as `didUpdateUnreadMessageCount(_ count: Int)`
    - or a conversation state object that includes unread count/read marker information

    The important behavior for our use case would be:

    - The count is available immediately when the app returns to foreground.
    - It does not depend on APNS delivery timing.
    - It is scoped to the active Messenger conversation/deployment/user.
    - It resets or reports `0` when the chat UI is open and messages are visible to the user.
    - It handles reconnect/history replay internally so the app does not need to parse recovered transcript data.
    - It avoids double-counting messages that may later arrive through live delegate callbacks after history recovery.

    Is our current approach of recovering chat data and reconciling `ChatElement`s the recommended workaround, or is there a better supported pattern?

    Thanks!

    #PlatformSDK


    #MobileMessenger
    #PlatformSDK

    ------------------------------
    Bartosz Kunat
    ------------------------------