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

notificationId in PushPayload is null for iOS #215

Open
AnastasiiaSob opened this issue Sep 2, 2024 · 5 comments
Open

notificationId in PushPayload is null for iOS #215

AnastasiiaSob opened this issue Sep 2, 2024 · 5 comments

Comments

@AnastasiiaSob
Copy link

AnastasiiaSob commented Sep 2, 2024

Preliminary Info

What Airship dependencies are you using?

airship_flutter: ^7.7.1

What are the versions of any relevant development tools you are using?

Flutter 3.22.3

Report

What unexpected behavior are you seeing?

After sending a push notification from Airship to my physical iOS device and calling Airship.push.onPushReceived.listen((event) {...} I get a PushPayload Object that contains the property notificationId with a null value. I can see the push notification on my screen and I see the payload in my console.
For example:
PushPayload( notificationId=null, alert=TEXT from Airship, title=title from airship, subtitle=null, extras={ com.urbanairship.metadata: eyJ2ZXJ...., com.urbanairship.media_attachment: {url: [......] }, ^u: https://www.google.com})

What is the expected behavior?

After sending a push notification from Airship to my physical iOS device and calling Airship.push.onPushReceived.listen((event) {...} I assume to get a PushPayload Object that contains a not-null property notificationId.

What are the steps to reproduce the unexpected behavior?

Send a push notification to an iOS device while the app is in foreground and active. Access the PushPayload Object event.pushPayload in the onPushReceived listener. The push notification is not a silent push.

Do you have logging for the issue?

In the info above.

@AnastasiiaSob AnastasiiaSob changed the title notification_id in PushPayload is null for iOS notificationId in PushPayload is null for iOS Sep 2, 2024
@rlepinski
Copy link
Collaborator

If you are trying to get the notification ID from a content-available push in the background, Apple does not deliver that id with the callback that we are given to listen for that event. There is a limitation on the Airship SDK where we are dropping the ID if the push is received in the foreground in the callback that we need to expose it to flutter. We can look into addressing that but it will take some time.

@AnastasiiaSob
Copy link
Author

@rlepinski yes, the is no notificationId with a content-available push in the background as well as in the foreground.
That would be of great value, as our feature implementation depends on the uniqueness check for push notifications based on the notificationId. For Android, there is a field 'com.urbanairship.push.CANONICAL_PUSH_ID' to access the notificationId ID.
Is there a workaround for now? Or could you estimate how long it would take to address this issue?

@rlepinski
Copy link
Collaborator

We wont be able to provide you the notification ID in the background for content-available push, only when the device is in the foreground.

A workaround would be to set your own unique ID, then use the getNotifications method and look for that ID in the extras.

@rlepinski
Copy link
Collaborator

@AnastasiiaSob I don't think we can solve your issue with just adding the foreground ID, that would catch some of it but the majority of the time notifications will be received in the BG. I think instead you should use this solution - #200 (comment)

Then use onPushReceived, onForeground events to pull your data from that store. That would be the most reliable way of getting the list of notifications

@AnastasiiaSob
Copy link
Author

@rlepinski thank you for your suggestion! We found out that in onPushReceived the notifications do have notificationId's if they are accessed through await Airship.push.activeNotifications. We took it as a workaround for now.

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