Code Monkey home page Code Monkey logo

Comments (2)

ekzyis avatar ekzyis commented on July 17, 2024 1

10.5 The pushsubscriptionchange Event

The pushsubscriptionchange event indicates a change in a push subscription that was triggered outside of the application's control, for example because it has been refreshed, revoked or lost.

To fire the "pushsubscriptionchange" event given a service worker registration of registration, newSubscription and oldSubscription, the user agent must fire a functional event named "pushsubscriptionchange" using PushSubscriptionChangeEvent on registration with the following properties:

  • newSubscription
  • oldSubscription

NOTE
Consider using a more reliable synchronization mechanism such as [WEB-BACKGROUND-SYNC] when sending the details of the new push subscription to your application server. The user might be subject to unreliable network conditions that could cause a fetch to fail.

-- https://w3c.github.io/push-api/#the-pushsubscriptionchange-event

10.5.2 PushSubscriptionChangeEventInit Interface

dictionary PushSubscriptionChangeEventInit : ExtendableEventInit {
  PushSubscription newSubscription = null;
  PushSubscription oldSubscription = null;
};

The newSubscription member details the push subscription that is valid per invocation of the pushsubscriptionchange event. The value will be null when no new push subscription could be established, for example because the web application has lost express permission.

The oldSubscription member details the push subscription that SHOULD NOT be used anymore. The value will be null when the user agent is not able to provide the full set of details, for example because of partial database corruption.

-- https://w3c.github.io/push-api/#pushsubscriptionchangeeventinit-interface

So I see following reasons why our code doesn't work:

  • it doesn't handle unreliable network conditions
  • it doesn't handle cases where oldSubscription is null or newSubscription is not null
  • it doesn't even get called or is never called with any data since it's still not supported by a lot of browsers

The last point is the most likely the issue, so I guess we need a workaround and can't rely on this event listener. Here is a post from 2019 how to do this.

from stacker.news.

huumn avatar huumn commented on July 17, 2024

Pretty impressive how unsupported it still is 4 years later.

from stacker.news.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.