showing notification badge in ios for expo notifications

Please provide the following:

  1. SDK Version: 4.22
  2. expo-notification SDK Version: 3.7
  3. Platforms(Android/iOS/web/all): iOS

I am using expo notification library to generate and manage notifications in my app [expo managed App]. I receive notifications properly however in iOS the notification badge is not coming for my app icon.
As per my research, there seems to be 2 ways to show badge:

  1. provide ‘badge’ property (badge count) while generating notification in notification payload
  2. set badge by using ‘setBadgeCountAsync’ & ‘getBadgeCountAsync’ methods when notification is received.

However I have question regarding both the approaches -
For approach 1,
how to provide correct badge count value while generating notification? Because the service generating notification does not know the current badge count on receiver’s device. Is there a way to get that count to provide it in notification payload?

For approach 2,
Expo provides notification received listeners when app is foregrounded [NotificationReceivedListener] or backgrounded [BackgroundNotificationTask]. However, it does not provide any listener when app is killed. So, is there a way to use ‘setBadgeCountAsync’ & ‘getBadgeCountAsync’ such that it set the proper badge count even if the app is killed?

Or is there any other way to achieve badge display for iOS?


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