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

[Bug]: Push Notification Modification at run time is not working #797

Closed
3 tasks done
FakharAlyas119 opened this issue Dec 7, 2023 · 3 comments
Closed
3 tasks done

Comments

@FakharAlyas119
Copy link

FakharAlyas119 commented Dec 7, 2023

What happened?

I am trying to modify the notification title and the body at run time and pass that OSNotification object to notificationEvent.complete(modified) but it's not working it shows the old notification the one without modification
I am using onesignal_flutter: ^3.5.1

Steps to reproduce?

1. install onesignal_flutter: ^3.5.1
2. push your notification from the dashboard
3. when you receive a notification at the mobile end modify it like this
    final modified = osNotificationModifier.toOpportunityLaunchNotification(
          notification,
          obj: toAppNotification,
        );
   toAppNotification is my object toOpportunityLaunchNotification function successfully returns the new OSNotification
4.  notificationEvent.complete(modified);
    this will show the un-modified notification

What did you expect to happen?

It should show the modified notification, but it shows an un-modified notification

OneSignal Flutter SDK version

onesignal_flutter: ^3.5.1

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@FakharAlyas119 FakharAlyas119 changed the title [Bug]: Push Notification at run time is not working [Bug]: Push Notification Modification at run time is not working Dec 7, 2023
@FakharAlyas119
Copy link
Author

I am using setNotificationWillShowInForegroundHandler this call back to modify the notification

@nan-li
Copy link
Contributor

nan-li commented Dec 11, 2023

Hi @FakharAlyas119, thanks for reporting.

  1. Can you share VERBOSE level logs starting right before the notification is received?
  2. Are you making a new OSNotification object and passing it into complete?
  3. Can you try modifying the OSNotification received in the event and passing that to complete and seeing what happens?

@jkasten2
Copy link
Member

setNotificationWillShowInForegroundHandler does not support modifying the notification. It only support omitting the notification.

We will consider this a feature request.

A workaround in the meantime is you can call complete(null) and display your own local notification.

@nan-li nan-li closed this as completed Mar 22, 2024
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

3 participants