mirror of
https://github.com/hanzoai/firebase-js-sdk.git
synced 2026-09-24 16:59:10 +00:00
Do nothing for action clicks (#702)
* Do nothing for action clicks * [AUTOMATED]: Prettier Code Styling * Address comment
This commit is contained in:
committed by
GitHub
parent
a51bf41bbe
commit
cfb9ca0d7a
@@ -159,11 +159,15 @@ export class SWController extends ControllerInterface {
|
||||
) {
|
||||
// Not an FCM notification, do nothing.
|
||||
return;
|
||||
} else if (event.action) {
|
||||
// User clicked on an action button.
|
||||
// This will allow devs to act on action button clicks by using a custom
|
||||
// onNotificationClick listener that they define.
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent other listeners from receiving the event
|
||||
event.stopImmediatePropagation();
|
||||
|
||||
event.notification.close();
|
||||
|
||||
const msgPayload: MessagePayload = event.notification.data[FCM_MSG];
|
||||
|
||||
@@ -517,6 +517,28 @@ describe('Firebase Messaging > *SWController', () => {
|
||||
expect(event.stopImmediatePropagation.callCount).to.equal(0);
|
||||
});
|
||||
|
||||
it('should do nothing for action clicks', async () => {
|
||||
const waitUntilSpy = sandbox.spy();
|
||||
const event: any = {
|
||||
notification: {
|
||||
data: {
|
||||
FCM_MSG: {
|
||||
notification: {}
|
||||
}
|
||||
},
|
||||
close: sandbox.spy()
|
||||
},
|
||||
waitUntil: waitUntilSpy,
|
||||
stopImmediatePropagation: sandbox.spy(),
|
||||
action: 'action1'
|
||||
};
|
||||
const swController = new SWController(app);
|
||||
|
||||
swController.onNotificationClick(event);
|
||||
|
||||
expect(event.stopImmediatePropagation.callCount).to.equal(0);
|
||||
});
|
||||
|
||||
it('should handle FCM notification without a notification data field', async () => {
|
||||
const waitUntilSpy = sandbox.spy();
|
||||
const event: any = {
|
||||
|
||||
Reference in New Issue
Block a user