-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Is there any way to clear notifications out from the app? #346
Comments
hi @rwillett or use |
Thanks, we'll look at these and see if the top one helps. We've played with the options but with another commercial plugin and couldn't get them to work the way we wanted. We'll try again with this one. Rob |
Or you could just use the stacking notification style so you can make a summary of the past notifications that belong to the same groupings. Read in details in here: https://github.com/phonegap/phonegap-plugin-push#stacking |
Thanks, we were aware of stacking, we use it on the Android version and that seems to mostly solve the problem there. On the iOS version, stacking isn't an option for us. I realise I hadn't actually stated which OS we were using , so have updated the original post to state its iOS. Stupid dumb mistake on our part. Rob |
Bump... cannot make this work. Clearing notifications work on iOS but not Android. Did anyone find a solution? |
Can I request a label or a status for this issue? |
@netomia Hey, not sure if we're allowed to post code here but I made mine work like this:
And I'm calling the method before the if statement at line 97 where it says if(message!=null ...)... This isn't necessarily the best solution but at the very least, from your server, you can send a delete tag in your payload ("delete" : 10) which will remove the notification you need. You can even send an otherwise empty push notification to clear it without creating a new notification. |
@Moghul - thanks! Although I can't seem to find the if(message!=null ...) at line 97. Would you mind checking and maybe c/p the lines where you call the function? |
Maybe it's because I am using an older version of the plugin. In the method onMessage(Context context, Intent intent), I have the following lines:
|
I just tried your code in the current version of the plugin, and I'm afraid it didn't work. I tested in on three devices with Android 4, 5 and 6. Thanks for the attempt though. |
This thread has been automatically locked. |
Hi,
We're trying to clear out notifications from our iOS app when in background mode.
Our notifications are very time dependent, we send personalised traffic information every 2-6 minutes to customers phones. If the customer is using the app and its in the foreground, then we can manage the information quite easily.
When the app is in the background, notifications keep getting sent and there can be a lot of them. A traffic incident could go on for 90 mins, so we could send 20 or so notifications updating the customer on the progress, if there are 2-3 incidents the customer is tracking then we could end up with 60-100 notifications, 95% of which are out of date and not longer relevant.
What we want to do is every time a new set of notifications come in AND the app is in the background, we want to clear out all the existing notifications and start again. This means that there should only be 3-4 notifications at any one time.
We've looked at doing this with phonegap-plugin-push and using cordova-plugin-local-notifications. If we send a silent notification using phonegap-plugin-push we can catch this in our app, and use cordova-plugin-local-notifications to send local notifications to the user. Since we control the local notifications, we can delete these as needed.
However when the app is not started, we no longer see any notifications as the app can't catch the silent notification, which means the app can't send the local notifications, which means the user is unaware.
So we have two choices (AFAIK),
Is anybody aware of how to clear out notifications from the app, @194 seems to indicate that this is intractable and not possible.
Thanks
Rob
The text was updated successfully, but these errors were encountered: