Skip to main content

flutter_native_badge_android 2.1.0 copy "flutter_native_badge_android: ^2.1.0" to clipboard
flutter_native_badge_android: ^2.1.0 copied to clipboard

PlatformAndroid

Android implementation of the flutter_native_badge plugin. Sets the app icon badge count through launcher badge APIs or a silent notification.

flutter_native_badge_android #

pub package

The Android implementation of flutter_native_badge.

Usage #

This package is endorsed, which means you can simply use flutter_native_badge normally. This package will be automatically included in your app when you do, so you do not need to add it to your pubspec.yaml.

However, if you import this package to use any of its APIs directly, you should add it to your pubspec.yaml as usual.

How it works #

Android has no public API for setting an app icon badge. Most launchers only badge an app icon while the app has an active notification, so this plugin:

  • On Huawei and Honor launchers, sets the count through the launcher's badge API. No notification is shown.
  • On all other launchers (Android 8.0+), posts a single silent, low-priority notification carrying the count, in a channel named App icon badge. It is removed when the badge is cleared, and tapping it opens the app.
  • On Android 13+ (API 33), requestPermission() requests the POST_NOTIFICATIONS runtime permission, which the notification needs.
  • Stores the last count set, which getBadgeCount() returns.

showRedDot() sets the badge count to 1, because Android launchers can't show a dot without a count.

Permissions #

The plugin adds these permissions to your app's manifest:

  • android.permission.POST_NOTIFICATIONS
  • com.huawei.android.launcher.permission.CHANGE_BADGE
  • com.hihonor.android.launcher.permission.CHANGE_BADGE
0
likes
160
points
1.38k
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Android implementation of the flutter_native_badge plugin. Sets the app icon badge count through launcher badge APIs or a silent notification.

Repository (GitHub)
View/report issues

Topics

#badge #notification #app-icon

License

MIT (license)

Dependencies

flutter, flutter_native_badge_platform_interface, meta

More

Packages that depend on flutter_native_badge_android

Packages that implement flutter_native_badge_android