Push notification Android上缺少推送数据';s PWA但不在桌面上

Push notification Android上缺少推送数据';s PWA但不在桌面上,push-notification,firebase-cloud-messaging,service-worker,progressive-web-apps,Push Notification,Firebase Cloud Messaging,Service Worker,Progressive Web Apps,更新:将Chrome从58更新到76解决了问题。根据这一点,Chrome v50+支持的有效载荷在这里并非如此。Chrome58可能存在缺陷/问题,或者代码中的某个地方存在缺陷。还是有兴趣了解一下 我正在按照相同的过程发送我的推送消息,无论是移动还是桌面 服务器(node.js): const webpush = require('web-push') const vapidKeys = { publicKey: '...', privateKey: '...', } webpus

更新:将Chrome从58更新到76解决了问题。根据这一点,Chrome v50+支持的有效载荷在这里并非如此。Chrome58可能存在缺陷/问题,或者代码中的某个地方存在缺陷。还是有兴趣了解一下

我正在按照相同的过程发送我的推送消息,无论是移动还是桌面

服务器(node.js):

const webpush = require('web-push')

const vapidKeys = {
  publicKey:  '...',
  privateKey: '...',
}

webpush.setVapidDetails(
  'mailto:...',
  vapidKeys.publicKey,
  vapidKeys.privateKey
)

sendTestPush(user) {
  webpush.sendNotification(user.subscription,
  `Test Push Here!\nJust a test push!`)
  .then(console.log)
  .catch(console.error)
}
self.addEventListener("push", function(event) {
  const data = event.data ? event.data.text().split('\n') : ["Title", "Body"]
  const options = {
    body: data[1]
  }
  const promiseChain = self.registration.showNotification(data[0], options)
  event.waitUntil(promiseChain)
})
输出:(手机和桌面都类似)

service worker.js:

const webpush = require('web-push')

const vapidKeys = {
  publicKey:  '...',
  privateKey: '...',
}

webpush.setVapidDetails(
  'mailto:...',
  vapidKeys.publicKey,
  vapidKeys.privateKey
)

sendTestPush(user) {
  webpush.sendNotification(user.subscription,
  `Test Push Here!\nJust a test push!`)
  .then(console.log)
  .catch(console.error)
}
self.addEventListener("push", function(event) {
  const data = event.data ? event.data.text().split('\n') : ["Title", "Body"]
  const options = {
    body: data[1]
  }
  const promiseChain = self.registration.showNotification(data[0], options)
  event.waitUntil(promiseChain)
})
在桌面上,我得到:

Test Push Here!
  Just a test push!
在手机上,我得到:

Title
  Body

service worker.js
在缺少
event.data
的情况下设置。是什么导致手机PWA上的数据丢失?

手机上运行的是什么浏览器和版本?不是所有的都支持有效载荷。@abraham Chrome 58,它支持有效载荷。