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

Add broader support for keeping track and removing notifications #104

Open
pAlkesz opened this issue Jan 1, 2025 · 1 comment
Open

Add broader support for keeping track and removing notifications #104

pAlkesz opened this issue Jan 1, 2025 · 1 comment

Comments

@pAlkesz
Copy link

pAlkesz commented Jan 1, 2025

KMPNotifier and Kotlin version:
kmpnotifier version: 1.4.0, kotlin version: 2.1.0

Describe the issue
I have an app where I want to remove/not display certain push notifications when the user is on a specific screen.
A good example for this use case is a chat app. When the user has the chat screen open with a certain person you want to silence the incoming push notifications from that chat.

If I let the KMPNotifier library show the push notifications automatically (which is great) then I do not know which notifications to remove because I can only remove notifications based on an Integer id which is randomized under the hood. I also do not want to remove all notifications.
Would it be possible to remove notifications based on the payload data?
Or get/set the IDs somehow to be able to keep track of them?

As a workaround currently I am trying to disable the automatic showing of the notifications and show the notifications manually so I can keep track of them. However this runs into issues again because I have two separate methods to work with:
onPushNotification and the onPayloadData

The onPushNotification only has the title and the body parameters within that I cannot call NotifierManager.getLocalNotifier().notify because I do not have the payload data received from the server and I want the payload data in the notification so I can get it back in the onNotificationClicked method.

And in the onPayloadData function I do not have the title and body of the notification.

I can think of several ugly workarounds to resolve this but I wanted to bring up this topic because maybe I am missing some obvious easy solution here. I am an Android dev first and there we receive the notification details next to the payload data in one method but I guess this is not the case on iOS.

Anyway do you have any suggestion on how to implement such functionality with this library?
Thanks in advance for the answer.

In which platform bug occurs?
android, ios

@mirzemehdi
Copy link
Owner

@pAlkesz Thanks for bringing up this

I actually totally agree with you, currently it will be kinda ugly workaround since onPushNotification and onPayloadData are in two different methods. I'll check this again, and if possible provide them in one listener function

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

2 participants