Google Chrome Silent Push Notifications

前端 未结 1 1980
孤城傲影
孤城傲影 2020-12-31 16:23

I\'ve been reading through the docs for Chrome\'s implementation of the Web Push API here, and I noticed the API says \"you promise to show a notification whenever you recei

相关标签:
1条回答
  • 2020-12-31 17:10

    You do have to show a notification, and if you don't show a notification you get a forced notification from the browser saying "This site has been updated in the background". But the requirements that show the scary message have been relaxed slightly:

    As of Jan. '16, it seems like up to the last 10 notifications are checked for whether each showed a notification or not. If one notification in the last ten notifications did not show a notification, that's considered an accident and the browser won't show the scary "This site has been updated in the background". You have to miss two notifications in the last ten for the scary message to appear.

    Note: If the URL in the address bar of the active browser tab matches the origin of your page, and the browser is not minimized, you are not required to show a notification. This is probably why your tests succeeded, if you were on the page itself while running your tests.

    Chromium bug that tracks the implementation: https://code.google.com/p/chromium/issues/detail?id=437277

    Relevant lines of source code: https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/push_messaging/push_messaging_notification_manager.cc&l=249

    0 讨论(0)
提交回复
热议问题