1

I like to develop a web app for mobile devices (Android) that will be served by a local server. The server should be able to send push notifications to the phones via the Push API.

The setup will have no connection to the internet and I can't find a note if the explained setup needs to connect to some cloud service in order to send the push notifications.

Losiowaty
  • 7,911
  • 2
  • 32
  • 47
jwillmer
  • 3,570
  • 5
  • 37
  • 73
  • There's nothing that can be done by a remote server that can't be done by a local one. You may have some issues with Doze mode on Android, but since you probably own the hardware (you are talking about a LAN app) you can whitelist the app if need be. – Gabe Sechan Feb 14 '17 at 15:38
  • Discussion on GitHub: https://github.com/GoogleChrome/push-notifications/issues/33#issuecomment-283348059 – jwillmer Mar 01 '17 at 14:25

2 Answers2

1

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").

Solid Snake
  • 130
  • 1
  • 7
0

@Mounica: May be I am a bit late, but just posting my answer in case it is helpful to you or others coming on this page. Your scenario can be addressed using MQTT Protocol within the Wi-Fi network. You will have to set up an MQTT Broker within the network and Make an MQTT Client in your iOs App. You can subscribe the MQTT Client to the MQTT broker on a topic same as GCM works and use MQTT Broker to send Push Notification to topics subscribed by MQTT Clients.

MQTT with Android Applications

Piyush
  • 1