当收到来自firebase云消息flutter的通知时,在图标启动器上添加徽章



当收到来自firebase的通知时,我使用flatter_app_badger包在图标启动器上添加徽章。但它只适用于onMessage。有什么解决方案吗?谢谢

分枝杆菌代码:

fcm.configure(

onMessage: (Map<String, dynamic> message) async {
print("onMessage: $message");
FlutterAppBadger.updateBadgeCount(1);

},
onBackgroundMessage: myBackgroundMessageHandler,
onLaunch: (Map<String, dynamic> message) async {
print("onLaunch: $message");
FlutterAppBadger.removeBadge();
},
onResume: (Map<String, dynamic> message) async {
print("onResume: $message");
},
);

假设您在myBackgroundMessageHandler回调中有这行:FlutterAppBadger.updateBadgeCount(1);,那么您可以按照本期文章中概述的步骤进行操作:

  1. 将此方法添加到Application.kt

    FlutterAppBadgerPlugin.registerWith(registry!!.registrarFor("fr.g123k.flutterappbadger"))
    
  2. [添加]此导入到Application.kt

    import fr.g123k.flutterappbadger.FlutterAppBadgerPlugin
    

相关内容

  • 没有找到相关文章

最新更新