feat(service-worker): handle 'notificationclick' events (#25860)
The previous version did not support the 'notificationclick' event. Add event handler for the event and provide an observable of clicked notifications in the SwPush service. Closes #20956, #22311 PR Close #25860
This commit is contained in:

committed by
Kara Erickson

parent
ea0a99610d
commit
cf6ea283bb
@ -88,6 +88,7 @@ const serverUpdate =
|
||||
scope.clients.getMock('default') !.queue.subscribe(msg => { mock.sendMessage(msg); });
|
||||
|
||||
mock.messages.subscribe(msg => { scope.handleMessage(msg, 'default'); });
|
||||
mock.messagesClicked.subscribe(msg => { scope.handleMessage(msg, 'default'); });
|
||||
|
||||
mock.setupSw();
|
||||
reg = mock.mockRegistration !;
|
||||
@ -128,5 +129,18 @@ const serverUpdate =
|
||||
});
|
||||
await gotPushNotice;
|
||||
});
|
||||
|
||||
async_it('receives push message click events', async() => {
|
||||
const push = new SwPush(comm);
|
||||
scope.updateServerState(serverUpdate);
|
||||
|
||||
const gotNotificationClick = (async() => {
|
||||
const event = await obsToSinglePromise(push.messagesClicked);
|
||||
expect(event).toEqual({action: 'clicked', notification: {clicked: true}});
|
||||
})();
|
||||
|
||||
await scope.handleClick({clicked: true}, 'clicked');
|
||||
await gotNotificationClick;
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
Reference in New Issue
Block a user