Skip to content

[messaging] Ability to change the notification before it's sent to the system tray #2639

Open
@helenaford

Description

@helenaford

What feature would you like to see?

Hi, is there anything on the roadmap to provide the ability to customise the notification before it's sent to the system tray. I'm a maintainer of notifee, and we recently added support to do this with iOS, we'd love to be able to do it with Android too.

Currently, the only option there seems to be is to send data messages. A couple of issues with this method are that you need to send two different types of messages based on whether the device is android or iOS, and having to keep track of which platform the token is registered with.

In addition to platform-dependent code, there's also different background restrictions for data-only vs notification messages (ref here).

On iOS, you can alter the notification using a Notification Service Extension where you have a brief amount of time to modify the notification before it's displayed to the user. in addition to the flexibility that message.apns.aps object offers where you can add a categoryId, sound, threadId e.t.c.

One possible solution could be to allow FirebaseMessagingService.onMessageReceived to be called for all app states, maybe a check somehow to see if the app does supports this, if not, default to handling with FCM? If this was possible, the one issue I do see with this, is that it could clash with other libraries like FlutterFire and react-native-firebase as you can only have one FirebaseMessagingService per app.

Another solution, which I think seems way easier and less intrusive is to have a separate service, like how iOS works, to alter the notification and nothing else.

I can see how this could be a big f/r, and maybe there's reasons that it's not been done?

The other possible solution is to expand the predefined set of user-visible keys for message.android, to include group and other NotificationCompat properties where possible.

To summarise, the two pain points I think there is at the moment with Android is:

  • the options allowed via message.android is limited.
  • no ability to intercept the notification before it's shown when the app is in background

How would you use it?

Tell us how you'd use this feature in your app.

This feature would allow users of this library to send notification messages and customise the notification before it's finally sent to the system tray.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions