setBadgeCountAsync is not causing badge count to change

Please provide the following:

  1. SDK Version: 42
  2. Platform: Android

I have run into an issue setting the badge count for my standalone Android app (through Internal testing). The intention was to set up a background fetch task to query the server for information from which I can derive a notification count which I set to the badge. I’ve since removed most of the complexity and narrowed the issue to the setting of the badge count itself. Through some extra logging I have been able to determine

  1. the task is running (around each minute or two)
  2. the result of setBadgeCountAsync is true
  3. after I set the badge count when I query for the badge number with getBadgeCountAsync, I get the value which I set (1 in this case).

The only problem is that the app icon on the home screen does not show any badge number. For context, I’m running on a Samsung Galaxy Note 20 Ultra with the Samsung launcher. When I search through settings for the app I can see that badge Icons are enabled. Does anyone have an idea what
could be happening?

Relevant code:

TaskManager.defineTask(BACKGROUND_FETCH_TASK, async () => {
  try {
    const user = await GLOBAL.getCurrentUser();
    if (user.role !== 'PATIENT') {
      await Notifications.setBadgeCountAsync(1);

      return BackgroundFetch.Result.NewData;
    } else {
      await updateTestLogs('no fetch needed')
      return BackgroundFetch.Result.NoData;
    }
  } catch (error) {
    Bugsnag.notify(error);
    return BackgroundFetch.Result.Failed;
  }
})

;

Hey @juuprz, from the looks of it you are doing everything correctly. By chance have you been able to test this on other physical android devices? I’d be interested to know if this is device/model-specific or a more widespread platform issue.

Cheers,
Adam

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.