2021年1月26日星期二

Flutter / Firebase Where should I update App Notification Badge Number?

I am developing mobile app with Flutter and Firebase.

I am just wondering about App Badge Count.

I am currently using 3rd party package flutter_app_badger for updating App badge Number

int unReadMessagCount = 0;      await gvDatabaseService.userJoinedChatRoomCollectionReference          .doc(authentication.currentUser.userID)          .collection('JoinedChatRoomList')          .get()          .then((jcrs) {        jcrs.docs.forEach((jcr) {          JoinedChatRoom joinedChatRoom =              JoinedChatRoom.fromDocument(jcr, chatRoomID: jcr.id);          unReadMessagCount += joinedChatRoom.unReadMessageCount;        });        FlutterAppBadger.updateBadgeCount(unReadMessagCount);  

but I don't know where I have to put this function,

there are some problems, for example , it is not executed when my app is terminated or running on background, so if I got new message when my app is not running, of course number is not updated,

Where should I put that code in order to update my badge number dynamically ?

Thanks for reading,,

I am waiting for your help.

https://stackoverflow.com/questions/65912758/flutter-firebase-where-should-i-update-app-notification-badge-number January 27, 2021 at 12:06PM

没有评论:

发表评论