Code Monkey home page Code Monkey logo

Comments (6)

sergioburdisso avatar sergioburdisso commented on August 23, 2024

That is the Message Server enpoint your serviceworker was subscribed to, that endpoint is the one your local(?) server has to send messages to (using the rest of information contained in the subscription object) in order for it to notify that serviceworker. Think of the Message Server as a proxy between your server and the client you want to notify. The "dialog" between your server and the Messe Server (in this case, fcm.googleapi.com) must be done in a very very precise way (partially defined here. That's why I ended up creating a Python package (solidwebpush) to carry out that work, the only thing you have to supply is the subscription JSON object and the message you want to send. Hope my answer helps you (even if it's just a little bit n.n).

from web-push-codelab.

jwillmer avatar jwillmer commented on August 23, 2024

Thx for the technical description of how the notification works. Do I understand you right that I can't use this solution offline? So if I am in a local network without internet connection I can't trigger a push notification on a phone in the same network (that does not have internet)? In other words: Is a connection to Google mandatory?

from web-push-codelab.

sergioburdisso avatar sergioburdisso commented on August 23, 2024

mmm I'm afraid you can't, each browser vendor subscribe the serviceWorkers to its own Message Server (Chrome: fcm.googleapi.com, Firefox: updates.push.services.mozilla.com, etc.), so it is something we don't have control over...

Although technically there's a solution, it would require you to sort of "hack" your network, namelly, it would require a Man In The Middle attack. You would have to code a program to redirect all your network traffic to that program (probably using raw sockets, and sending ARP packets), and then make that program listen for request to those Message Servers (those request will be over HTTPS - port 443), then your program has to send exactly the same response the real Message Server would send. It's is not an easy task.... but it is the only solution I cant think of.

Note: Your browser will block any serviceWorker registration that is not over a "secure connection", that means that your server MUST be serving request over HTTPS or you could install your web app locally on your users devices (so that they can be accessed by "localhost").

from web-push-codelab.

jwillmer avatar jwillmer commented on August 23, 2024

O.K. so bad news for me. The described scenario is the one I am facing. I created a Stackoverflow question about this. If you like you can post your answer there as well (and I accept it as answer) or I will reference it to this issue.

from web-push-codelab.

sergioburdisso avatar sergioburdisso commented on August 23, 2024

Ok!

from web-push-codelab.

gauntface avatar gauntface commented on August 23, 2024

Thanks for discussing this and coming to a conclusion.

from web-push-codelab.

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.