-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
[Enhancement] Allow iOS, like Android, to customize the push notifications #83
Comments
Hi @GHGiampy thanks for reporting this. I was thinking about such a thing in the past too. Does that make sense? Is this what you're aiming for with this issue? |
Hi @thomasgalliker, do you have a branch and commit hash to use for testing version 2.5.34-pre (or are we now looking at version 2.5.35)? I agree that a message should only be displayed in cases of high priority, regardless of other message settings. However, I would still leave the final choice on how to handle the message to the app itself. My goal was to have the message visible as a banner only if the app is in foreground, while, if the app is closed or open in the background, the message should be standard (e.g., in the tray for Android). BTW: I noticed that even in the latest versions of the code, |
The released version 2.5.35 uses the main branch as code base. Instead of manipulating the data payload (which I personally think is rather hacky), I'd rather prefer something similar to |
I see and agree with you.
But what if someone wants to show the notification as a banner when the app is in the foreground? One idea could be to expose a method to call inside the What I've said so far is valid unless I'm overlooking a simple solution for displaying notifications with the app in the foreground. |
First feedback, for now only on Android with v2.5.35.
Which I assume that it sets the default importance/priority of the received notifications; the push notification are shown also in foreground but different warnings and errors can be seen in the log:
Also trying to create my custom default notification channel as suggested, the warnings (and the errors) remain:
|
Ah I forgot to say that with this version I was no more able to show the notification as a banner, with the hacky code or sending an high priority push notification with:
|
Summary
Currently using the
NotificationReceived
event, only on Android, we can change the behavior of the push notification before it is processed simply modifying theData
dictionary in theFirebasePushNotificationDataEventArgs
received.This request allows also iOS to customize the push notification.
API Changes
No API changes are required, the workaround is to move a simple line of code a couple of rows earlier.
We are using the v2.5.13, so supposing it is the
main
branch, moving the line 273 after the 267 here:Plugin.FirebasePushNotifications/Plugin.FirebasePushNotifications/Platforms/iOS/FirebasePushNotificationManager.cs
Lines 266 to 274 in 92017ea
allows the
notificationPresentationOptions
to be filled based on the Data modified by theNotificationReceived
event, as a consequence this allows us to customize the push notification, exactly as in Android, before it is handled or created.The same can be achieved for the
develop
branch here:Plugin.FirebasePushNotifications/Plugin.FirebasePushNotifications/Platforms/iOS/FirebasePushNotificationManager.cs
Lines 320 to 328 in 4629de3
Moving the line 327 after the 321.
Intended Use Case
With this modification we can use code like this:
Which works on both, Android and iOS.
The text was updated successfully, but these errors were encountered: