I have created a new application in which for showing notification used NotificationCompat Notify method. Defining a functionality that notification should get dismissed only on clicking it or swiping it.
It should not get dismissed on opening app via launcher (same like telegram app)
Tried so far,
setAutocancel method to dismiss the notification on clicking or swiping.
but I couldn't able to stop the dismiss when app gets opened via launcher
Also, I have tried showing notification using foreground service but it is not supporting swipe dismiss behaviour.
Is there anyway to support swipe dismiss and notification shouldn't get dismissed when I open app via app launcher
Related
I actually want to show a screen or custom notification with sound which allow user to accept or decline a call just like whatsapp/skype.
I used firebase messaging to send notification to the particular user which trigger the method define in backgroundNotificationHandler. When the app is minimized or not even on the background the method only able to show me the toast message, But when I try to open a dialog or foreground service it giving me error. The error seems like it not getting the context.
FirebaseMessaging.onBackgroundMessage(backgroundNotificationHandler);
The same code working when the app is open to the user
Using zo0r react-native-push-notification https://github.com/zo0r/react-native-push-notification
the app is able to receive push notifications from server both when the app is in background and foreground. If the app is open it needs to act immediately on data provided in the notification, and when in background, it needs to act on the data when the app is opened.
However, the onNotification callback is only invoked when notification is tapped by the user. In my case I would like to have the callback invoked right away when the user opens the app (if background), and immediately if the app is in foreground. How can that be achieved for an android device? It works fine on iOS.
My app receives FCM and fires local notifications, which open target activities. This works fine if the local notification is clicked when the app is not running.
But, if the local notification is clicked when my app is already running (foreground or background), I don't want to open the target activity but shows an AlertDialog first. So, the activities stack is not changed and the user can continue what he was doing before.
It seems the local notification must have an action, which opens activities. Is there anyway achieve what I wanted above?
I think you have to stop sending push notification when you app is in foreground
check if your app is in foreground or by following this link
check android application is in foreground or not?
check this in firebaseMessegingService class before sending PN and manage alert dialog appearance according that
I'm building an Android app which creates notifications. Each notification has a number of additional actions.
The default application (when the user taps on the notification) launches an activity in my app. That's working fine.
When the user swipes the notification to dismiss the notification, my app responds by doing some deletion work, and the user is left on the list of notifications. The one that the user swiped is removed from the list.
For some of my additional actions I want to launch activities, and that's working fine; for the other actions, I want my app to do some work but I also want the user to remain on the notification list. I'm struggling to find a way to do this last part - all my attempts to configure the intent and pending intent for my additional action result in behaviour whereby when the user clicks on the action, the notification list disappears.
Is there any way to get what I want (i.e. a notification additional action which performs work but leaves the user on the notification list)? Do I need to build a custom notification layout or something?
The Android Wear OS has recently been updated to 5.0, which includes the feature to "recover" the most recently dismissed notification.
As a consequence, a notification's delete intent is only triggered after the user can no longer recover the intent (after another notification is dismissed, or the user swipes down and lets the 'dismiss' timeout expire).
I am attempting to display a notification, which gets updated fairly regularly until the user dismisses it. For this, I need to know immediately when the user has dismissed the notification (before the "recover" option has expired), so that I can stop updating the notification. If I attempt to update the notification once it has been dismissed, it will launch a new notification. In effect, the notification can't be dismissed as it will be recreated immediately.
So my question is: Has anyone discovered a way to detect immediately when the user dismisses a notification on an Android Wear device, before the option to recover the notification expires? I suspect if such a method exists, it should also be possible to detect when the user recovers the notification.
How about this?
Setting this flag will make it so the notification is automatically canceled when the user clicks it in the panel. The PendingIntent set with setDeleteIntent(PendingIntent) will be broadcast when the notification is canceled.
public NotificationCompat.Builder setAutoCancel (boolean autoCancel)
As I see it, it dismisses the notification immediately and it sends the setDeleteIntent() at the same time