-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent ReceivedNotification from being displayed #91
Comments
I need the feature too. By the moment I'm controlling the receiver presence for sending it or not. It could be interesting to control what is receiving in the notification and display it or not. For example, a chat application receives a notification and shows it but, if the chat room (where the notification was generated) is opened, the notification shouldn’t be displayed. |
You can control this, the way I am doing it is (adjusted for your needs); Create a global variable 'int chatroomActiveID = null'; In the widget that shows the chatroom screen; set the global variable in the 'initState()', and set it back to null in the 'dispose()'.
Then import your chatRoom dart file (where the global variable is located) to the file which contains your 'createdStream.listen(...)' logic. Now in this logic
|
Try to use the properties |
I've tested this option but only works in Android. In iOS the I've implemented it because at least in Android works fine.
I've also implemented that solution controlling the OS. When sending the notification: bool displayInForeground = device.os == "android"; In Android, the behavior is what I was looking for. In iOS, the notification doesn't appear when the application is opened. Thanks for your work! 😄 |
Is there any way that a
ReceivedNotification
can be prevented to reach thedisplayedStream
inside/during thecreatedStream
?I am aware that I can
AwesomeNotifications().cancel(id)
during the thecreatedStream
phase but this wouldn't be applicable to my use case.I am creating messaging notifications with the
Inbox
layout, and either I am using this wrong but if I don't use the sameNotificationContent.ID
, a separate notification/status bar icon will be created for each notification. Reusing theNotificationContent.ID
properly nests the notifications inside one Inbox layout notification, but cancel(id) would remove all the nested messages.Why? My application runs a background poller for updates in case Firebase fails to push the notification, and then I manually create a notification with
AwesomeNotifications().createNotification(content: ...)
.However sometimes Firebase would push a notifcation a great deal later when my background poller already created the notifcation in question, thus a duplicate would occur, and it is this duplicate that I wish to prevent from being displayed.
Thanks in advance,
Gilles
(awesome package indeed by the way!)
The text was updated successfully, but these errors were encountered: