--- a/mobile/android/components/PersistentNotificationHandler.js
+++ b/mobile/android/components/PersistentNotificationHandler.js
@@ -26,32 +26,53 @@ PersistentNotificationHandler.prototype
classID: Components.ID("{75390fe7-f8a3-423a-b3b1-258d7eabed40}"),
observe(subject, topic, data) {
if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_DEFAULT) {
Cu.import("resource://gre/modules/NotificationDB.jsm");
}
const persistentInfo = JSON.parse(data);
- notificationStorage.getByID(persistentInfo.origin, persistentInfo.id, {
- handle(id, title, dir, lang, body, tag, icon, data, behavior, serviceWorkerRegistrationScope) {
- serviceWorkerManager.sendNotificationClickEvent(
- persistentInfo.originSuffix,
- serviceWorkerRegistrationScope,
- id,
- title,
- dir,
- lang,
- body,
- tag,
- icon,
- data,
- behavior
- );
- notificationStorage.delete(persistentInfo.origin, persistentInfo.id);
- }
- });
+ if (topic === 'persistent-notification-click') {
+ notificationStorage.getByID(persistentInfo.origin, persistentInfo.id, {
+ handle(id, title, dir, lang, body, tag, icon, data, behavior, serviceWorkerRegistrationScope) {
+ serviceWorkerManager.sendNotificationClickEvent(
+ persistentInfo.originSuffix,
+ serviceWorkerRegistrationScope,
+ id,
+ title,
+ dir,
+ lang,
+ body,
+ tag,
+ icon,
+ data,
+ behavior
+ );
+ notificationStorage.delete(persistentInfo.origin, persistentInfo.id);
+ }
+ });
+ } else if (topic === 'persistent-notification-close') {
+ notificationStorage.getByID(persistentInfo.origin, persistentInfo.id, {
+ handle(id, title, dir, lang, body, tag, icon, data, behavior, serviceWorkerRegistrationScope) {
+ serviceWorkerManager.sendNotificationCloseEvent(
+ persistentInfo.originSuffix,
+ serviceWorkerRegistrationScope,
+ id,
+ title,
+ dir,
+ lang,
+ body,
+ tag,
+ icon,
+ data,
+ behavior
+ );
+ notificationStorage.delete(persistentInfo.origin, persistentInfo.id);
+ }
+ });
+ }
}
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([
PersistentNotificationHandler
]);