Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Clearing all notifications remotely (via a stealth notification) Android/iOS #2371

Open
Moghul opened this issue May 17, 2018 · 1 comment
Open

Comments

@Moghul
Copy link

Moghul commented May 17, 2018

Expected Behaviour

You send a notification with a "data" payload containing a "clearAllNotifications": "true" key, and the existing notifications disappear.

Actual Behaviour

N/A

Reproduce Scenario (including but not limited to)

N/A

Steps to Reproduce

N/A

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Any platform where code may be run when a notification is received.

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

N/A

Cordova CLI version and cordova platform version

N/A

Plugin version

cordova plugin version | grep phonegap-plugin-push   # e.g. 1.5.3

Developed and tested on 2.1.2

Sample Push Data Payload

{
    "priority" : "high",
    "content_available" : true,
    "data" : {
      "notId": 0,
      "clearAllNotifications" : "true"
    },
    "to" : "id"
}

Sample Code that illustrates the problem

See PR when it's made

Logs taken while reproducing problem

N/A

What do I want?
I want to be able to remotely trigger the removal of all existing notifications via a hidden notification.

Why do I want it?
Because my notifications are time-sensitive and they become irrelevant after a couple hours.

Why not do it in the "Send custom payload -> pass it to JS -> have JS call plugin to clear all notifications" workflow?
It seems convoluted to me to do it that way and it introduces multiple points of failure. The code to clear notifications must be native, so why not just make it a feature?

I'll have a PR attached to this ASAP so you can take a look at the code.
Note that I don't know objective-c so I just made a thing that works but to which you'll likely cringe. Java is likely easy to improve as well.

@Moghul
Copy link
Author

Moghul commented May 18, 2018

@macdonst this ought to work for background ios apps too. Just not force-closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants