服务人员显示相同的通知2次

时间:2018-09-05 06:52:09

标签: push-notification angular5 service-worker

我已经使用FCM实现了Web psuh通知。在后端工作正常。在angular5的前端,我已经使用Service Worker来获取该推送通知。在该功能上,它仅输入一次,但有时会显示2条通知,一个带有图标,另一个不带图标。

function showNotification(title, options) {
  var notificationOptions = {
    'tag': options.tag,
    'badge': 'assets/icons/icon-128x128.png',
    'icon': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/images/logos/logo-icon.png',
    'vibrate': [300, 100, 200, 400, 500],
    'data': options.data,
    'body': options.body,
    'sound': 'default'
  };
  if(options.data.type === 'media') {
    notificationOptions.image = options.data.media;
  } else {
    notificationOptions.body = options.body;
  }
  return self.registration.showNotification(title, notificationOptions);
}

我已经搜索了这一点,但没有任何解决方法。

提前谢谢。任何帮助将不胜感激。

0 个答案:

没有答案