I'm using cloud function to send notifications by using device tokens.
const payload: admin.messaging.MessagingPayload = {
notification: {
title: `updatedBy: ${updatedBy}`,
body: `nova messagem ${increment}`,
},
}
return fcm.sendToDevice(userToken, payload, options).then((value) => {
console.log(value.results);
}).catch((error) => {
console.log(error);
})
But, all notification got pilled, I wanna so much to administrate these notification that stay stuck in system tray, is there anyway I can moderate notifications with such "complexity" using these plugins? (Local push Notification, FCM, cloudfunctions) without using native code (kotlin, android)? because I don't know how the android structure work...
I can use cancelAll (of Local push notification)
FlutterLocalNotificationsPlugin.cancelAll()
from Local Push Notification: https://pub.dev/documentation/flutter_local_notifications/latest/
But is too inflexible
I can also use cancel notification using an specific "ID", but I don't know how to get that notification "id"
FlutterLocalNotificationsPlugin.cancel(notificationId)
so, How can solve this issue?
In that way I can wisely remove whatever notification I want, But basically, I just wanna collapse notification that is the same type, like on Whatsapp, when a person send you more than 1 message, and in the system tray, there's only one notification saying that "he" sent more than 1 message (and not a heavy pile of notification).
I just looked at https://github.com/chetdeva/collapsing-notifications/tree/a5e8867e24f53ff8caca761c7faa13242c607dba
This github code is for the article https://medium.com/fueled-engineering/collapsing-fcm-notification-like-a-pro-102a4946b350
would be perfect if it would not too difficult to implement in a flutter project, I also looked at every post here, in stackoverflow, seens that no one yet ever answered this question
[EDIT]: the reason I can't use
FlutterLocalNotificationsPlugin.cancelAll()
It's because I'm using fcm method to listen for notifications, I tried to put that method in some of fcm listener but not succeed.
_firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
print('on message $message');
},
onResume: (Map<String, dynamic> message) async {
print('on resume $message');
},
onLaunch: (Map<String, dynamic> message) async {
print('on launch $message');
},
);
Use the "collapse key" mentioned in the docs: https://firebase.google.com/docs/cloud-messaging/concept-options#ttl
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.