Skip to content
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

PushNotification.getDeliveredNotifications issue #1947

Open
artymir opened this issue Apr 8, 2021 · 11 comments
Open

PushNotification.getDeliveredNotifications issue #1947

artymir opened this issue Apr 8, 2021 · 11 comments

Comments

@artymir
Copy link

artymir commented Apr 8, 2021

Hi, @Dallas62
PushNotification.getDeliveredNotifications return to me
[{"body": "4", "group": null, "identifier": "0", "tag": "FCM-Notification:78159278", "title": "7"}]

Identifier is "0" for all my remote notifications? What i doing wrong?

How can i use PushNotification.removeDeliveredNotifications(identifiers)?

@ge0rg
Copy link
Contributor

ge0rg commented Apr 15, 2021

This looks like an issue in the Android SDK, as the code is a straight-forward wrapper around Notification.getId().

I don't yet know if you could do clearNotification(tag, 0) or if another workaround is needed still. However, I'd like to have a way to replace an FCM notification with a local notification that adds information.

@Dallas62
Copy link
Collaborator

Hi,
Can you provide at least a reproducible exemple ?
Such as the notification payload ?

I suspect that the id send is not a valid int32.

Regards,

@Dallas62
Copy link
Collaborator

@ge0rg you can do it by sending data only and pass data to the local notification method.

@ge0rg
Copy link
Contributor

ge0rg commented Apr 15, 2021

Here's how it looks like when a bunch of backend notifications arrive and we start the app afterwards:

Code:

PushNotification.getDeliveredNotifications((notifcations) => {
    console.log(notifcations);
});

Output (re-formatted for clarity):

[
  {
    "body": "New chat message",
    "group": null,
    "identifier": "0",
    "tag": "JcrkNx5Y6jMGevAsc39Tb4",
    "title": null
  },
  {
    "body": "New chat message",
    "group": null,
    "identifier": "0",
    "tag": "3tZHVAjoX6y8vnakLb3SoF",
    "title": null
  },
  {
    "body": "New chat message",
    "group": null,
    "identifier": "0",
    "tag": "FbS4ZiHKdts69PdZXjbEst",
    "title": null
  },
  {
    "body": "New chat message",
    "group": null,
    "identifier": "0",
    "tag": "NK2M3VLwww5DFLFy8Rqrzc",
    "title": null
  }
]

I'm sending the notifications via FCM, where I can add a tag but have no way to define the id. I would have expected that Android would just auto-generate auto-increment IDs then, but that's apparently not the case.

@Dallas62 I'd love to send data only and create local notifications. In fact, that is my primary approach. However, in some situations a data notification won't wake up the app, so I fall back to noisy notifications after some minutes if the app doesn't query the API. In that case, I need to later consolidate the FCM notifications that have a body with the local notifications, ideally without causing a new notification sound.

@Dallas62
Copy link
Collaborator

I will try to look at this, but I think Firebase provide an ID which is not a valid int32.
The result is that the id is not generated cause there is one defined (but not valid).

@ge0rg
Copy link
Contributor

ge0rg commented Apr 15, 2021

Could you provide an alternative API to cancel and modify notifications based on their tag? Maybe internally, you'd need to loop through all existing notifications, check their tag and modify the according one. I have no idea though if Android will allow modifying a notification that has no proper ID.

@Dallas62 Dallas62 pinned this issue Apr 16, 2021
@ucheol2
Copy link

ucheol2 commented Jun 23, 2021

I have same problem

1 similar comment
@litinskii
Copy link

I have same problem

@branislavantic87
Copy link

branislavantic87 commented Jul 9, 2021

I have same issue, and also PushNotification.removeDeliveredNotifications(identifiers) does not delete notifications with 0 identifier.
Also I have a question why getDeliveredNotification object does can't contain userInfo object(which works great on ios)?

@NihiIist
Copy link

I have same issue. Identifier is always "0", and it only happens on Android.

@bearlin5
Copy link

issue info:
android device receives remote notification[use my server send notification to fcm] (app in background/ is closed), then app go to foreground and invoke PushNotification.getDeliveredNotifications. ===>this notification can be not remove by using "PushNotification.removeDeliveredNotifications(identifiers)"
LOG [{"body": "message 12345", "group": null, "identifier": "0", "tag": "FCM-Notification:608230904", "title": "title-12345"}]

android device receives remote notification[use my server send notification to fcm] (app in foreground), then app invoke PushNotification.getDeliveredNotifications. ===>this notification can be remove by using "PushNotification.removeDeliveredNotifications(identifiers)"
LOG [{ "body": "12191700", "group": null, "identifier": "-1397444380", "tag": null,"title": "12191700"}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants