Simpler api for informing GV about web notification click / dismiss
Categories
(GeckoView :: General, enhancement, P1)
Tracking
(firefox-esr91 wontfix, firefox98 wontfix, firefox99 wontfix, firefox100 fixed)
People
(Reporter: petru, Assigned: agi)
References
Details
(Whiteboard: [geckoview:m100])
Attachments
(1 file)
Based on the discussions from https://github.com/mozilla-mobile/android-components/issues/7477
I see the web notifications needing to work even if the user closes the application in the meantime (and removes it from task manager).
Looking at what happens when a notification is clicked / dismissed it looks like only two strings are needed to identify the notification with which the user interacted [1].
But to be able to call the current methods we'd need to go through the WebNotification
class.
I'm proposing a simpler approach for notifications, something along the lines of "post and forget":
WebNotificationDelegate.onShowNotification
will function the same - sends to integrators aWebNotification
with all details based on which native notification to be created and shown- [NEW] Integrators will add as intent extras to the native notification
WebNotification
stag
andcookie
properties.
For this GeckoView first needs to exposemCookie
. - Users can click / dismiss the native notification. A PendingIntent will inform the app about these events.
- [NEW] The receiving component will read the
tag
andcookie
extras from the native notification's intent. - [NEW] The receiving component needs a simpler API to pass these details to
GeckoAppShell.onNotificationClick(tag, mCookie)
.
Jonathan proposed
geckoRuntime.webNotificationController.dismissNotification(tag, cookie)
By using this approach neither do apps, neither do GeckoView need to keep a reference to WebNotification
s. The apps can can even be killed and everything will still work as expected when users click or dismiss a certain web notification.
Assignee | ||
Comment 1•2 years ago
|
||
I responded on Slack but, I would rather offer a way to serialize the WebNotification
object to a string so that it can be re-created at a later date, would that work for you? I would rather not expose internals of the notification.
Updated•2 years ago
|
Reporter | ||
Comment 2•2 years ago
|
||
(In reply to Agi Sferro | :agi | [slow ni? rn sorry] | ⏰ PST | he/him from comment #1)
I responded on Slack but, I would rather offer a way to serialize the
WebNotification
object to a string so that it can be re-created at a later date, would that work for you? I would rather not expose internals of the notification.
With the intended usage of still "persisting" this through a native notification extra?
This would work great! - still a simple, straightforward usage for us.
Going by the properties of the WebNotification
the only thing that would worry me is the imageUrl
- which could be a a big data url? So maybe this field can be left out when serializing the notification?
Assignee | ||
Comment 3•2 years ago
|
||
Apps want to persist a WebNotification so that they can respond to taps on it
when the app is not alive anymore.
To achive this, we make WebNotification serializable through Parcel so that the
app can store it somewhere.
Updated•2 years ago
|
Updated•2 years ago
|
Pushed by asferro@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3d305df975f3 Implement Parcelable for WebNotification. r=jonalmeida
Comment 5•2 years ago
|
||
bugherder |
Updated•2 years ago
|
Description
•