Skip to main content

Notification center

Show a badge with the number of notifications the user has not seen in the community, to bring them back to what is new.

Android availableiOS availableFlutter availableReact Native availableUnity available

Before you begin​

  • Complete the Quickstart: the SDK is initialized and the community screen opens in your app.
  • Pick where the badge goes in your app, for example on the tab or the button that opens the community.

How it works​

The community has its own notification center, inside the Octopus UI: it lists what other members did that concerns the user. The not-seen count is the number of entries the user has not seen there yet.

The count does not depend on push notifications: it works whether or not you set up Push notifications, and the user does not need to grant the notification permission.

The SDK publishes the count and updates it when it changes; ask for a refresh from the server when you need the latest value, for example when your app comes to the foreground.


Show the not-seen count​

Collect OctopusSDK.notSeenNotificationsCount, a Flow<Int>. updateNotSeenNotificationsCount() is a suspend function that fetches the count and returns it as an OctopusResult<Int, Nothing>:

lifecycleScope.launch {
OctopusSDK.notSeenNotificationsCount.collect { count ->
// Update your badge
}
}

lifecycleScope.launch {
OctopusSDK.updateNotSeenNotificationsCount()
}

The Android sample's SettingsViewModel collects notSeenNotificationsCount for its Debug info row and Community tab badge, and ScenariosViewModel calls updateNotSeenNotificationsCount().

Next steps​