yumi0629 / flutter_app_badge

Add unread count badges to Android & iOS devices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

app_badge

Add unread count badges to Android & iOS devices.
为APP桌面图标添加角标

Usage:

AppBadge.setAppBadge(count);

Notice:

The plugin doesn't support AndroidX !! If your project has migrated to androidX, please migrate this plugin to androidX manually. See more: Migrate to androidX .

Support Devices

  • APPLE
  • HUAWEI
  • SAMSUNG
  • XIOAMI
  • GOOGLE
  • MEIZU
  • VIVO
  • OPPO

Add Custom Devices

  • First, create a custom ModelImpl xxxModelImpl extends IconBadgeNumModel and override the function setIconBadgeNum():
class xxxModelImpl:IconBadgeNumModel {
    override fun setIconBadgeNum(context: Context, notification: Notification, count: Int): Notification {
        // return something...
    }
}
  • Then, create a new custom launcher type in enum launchType in file LauncherHelper.kt, add put the type mapping to file IconBadgeNumManger.kt:
enum class LauncherType {
    GOOGLE,
    HUAWEI,
    MEIZU,
    XIAOMI,
    OPPO,
    VIVO,
    SAMSUNG,
    XXX
}
@Throws(Exception::class)
    private fun getIconBadgeNumModelByLauncher(launcherType: LauncherType): IconBadgeNumModel {
        when (launcherType) {
            ······
            LauncherType.XXX -> return xxxModelImpl()
            else -> throw Exception("not support your phone [ Build.MANUFACTURER is null ] $launcherType")
        }
    }

Welcome to PR if you can fit other Android devices !!!

About

Add unread count badges to Android & iOS devices.

License:Other


Languages

Language:Kotlin 57.8%Language:Dart 16.6%Language:Ruby 13.8%Language:Objective-C 7.6%Language:Swift 4.3%