resetBadgeCountAndRemoveNotificationsFromCenter static method

Future<void> resetBadgeCountAndRemoveNotificationsFromCenter()

Sets the iOS applicationIconBadgeNumber to 0, thus removing the badge count from the app icon. Doing this also means that the notifications are removed from the iOS notifications center at the same time.

This is iOS-specific, as Android clears the 'notification count' automatically when notifications are dismissed.

Implementation

static Future<void> resetBadgeCountAndRemoveNotificationsFromCenter() async {
  if (Platform.isIOS) {
    try {
      await _channel
          .invokeMethod('resetBadgeCountAndRemoveNotificationsFromCenter');
    } on PlatformException catch (e) {
      print('Failed to reset badge count for following reason: ${e.message}');
    }
  }
}