如何使用 PwPush 在 angular 中打开应用程序时防止推送通知

How to prevent push notification when app is open in angular using PwPush

我正在使用 PwPush 将通知从服务器推送到桌面。现在,如果我的 angular 应用程序已经在 chrome 中打开,我不想看到推送通知,我只想更新 UI。现在,即使应用程序打开或关闭,我也只会收到推送通知。在 angular 中有没有办法实现这一点?

看来我走错了路。推送通知显示我是否发送带有通知键值对的负载。但是如果我发送没有通知密钥的简单有效负载,那么一切都会像我想要的那样正常工作。我仍然收到消息,但未显示通知

为了可视化,我从这里更改了有效负载

      let payload = {
        notification: {
            title: 'Title',
            body: 'This is my body',
            
            icon: 'assets/icons/icon-384x384.png',
            actions: [
                { action: 'bar', title: 'Focus last' },
                { action: 'baz', title: 'Navigate last' },
            ],
            data: {
                onActionClick: {
                    default: { operation: 'openWindow' },
                    bar: {
                        operation: 'focusLastFocusedOrOpen',
                        url: 'https://www.google.com',
                    },
                    baz: {
                        operation: 'navigateLastFocusedOrOpen',
                        url: '/signin',
                    },
                },
                url:"https://www.google.com",
            },
        },
    };

至此

      let payload = {
        "body":"some stuff",
    };