Getting the notification count without initializing the SDK
An app that only shows a notification badge doesn’t need to initialize the Unblu mobile SDK. Initializing it loads a webview and opens a permanent connection to the Collaboration Server.
The web API endpoint /persons/getNotificationCountForCurrentPerson returns the notification count of the person making the request. Both mobile SDKs include a helper that calls it directly.
What the count covers
The endpoint returns a personId and a totalNotificationCount. This is the sum of that person’s notifications across all their conversations. Each message the person receives and hasn’t read yet counts as one notification.
What the helper needs
The helper doesn’t initialize the SDK. The server identifies the person from the custom cookies and the access token or OAuth token in the UnbluClientConfiguration you pass the helper. If the configuration has no custom cookies and no token, the server treats the request as coming from an anonymous visitor.
In practice, you pass the same configuration you would use to create a visitor client. The helper therefore suits apps that have already run an authenticated Unblu session on the device, or that can supply custom cookies or an access or OAuth token of their own.
An anonymous visitor with no person record yet is a special case. The call succeeds and returns a count of 0 with no person ID, rather than failing. A zero badge and a visitor who doesn’t exist yet look the same to your app.
One request per call
The helper sends one request and returns the result. It doesn’t poll, cache, or schedule anything. How often your app asks for the notification count is up to you.
Other notification count endpoints
Two other endpoints return notification counts for a person you name:
-
/persons/{personId}/getNotificationCountreturns the count for a given person. -
/persons/{personId}/getNotificationCountForConversationsreturns the count for a given person across the conversations you list.
Both require the REGISTERED_USER role and an internal entry path, so a visitor app can’t call either of them.
See also
-
For the helper’s signature and an example, refer to the notification count sections of the notification articles for Android and iOS.
-
For an overview of how Unblu delivers notifications, refer to Push notifications.