Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is posible use android push notifications in lan? without internet [closed]

My question is: Can I implement android push notifications in a lan enviroment?

Any tips to do it?

thanks!

like image 699
Wolobi Avatar asked Oct 31 '19 09:10

Wolobi


1 Answers

No. Without the internet, it is not possible to stimulate the OS Push Notification triggering system manually separate to the official OS vendor infrastructure.

There might be a way to do so, with a non-standard means:

  • Spoofed DNS
  • Stolen Push Notifications Certificate
  • (Manually inserted CA [although the certificate is likely pinned in the app])
  • Root OS override

Without the battery saving mechanism, it's still possible to communicate with an app, but not as "reliably" nor as "battery-efficiently".

Workarounds:

  • Keeping your app awake (there are techniques for doing this but not always reliable across many types of devices); AND
  • Your own network channel (TCP connection, HTTP/TCP connection, TCP Polling, HTTP Polling)
  • As a backup, the User can help keep the app running. An indicator can help, showing the user whether or not the app is still connected to the server. For user-reliability, you might be able to display a notification to the user, when the app is about to "deactivate", so the user can help and reactivate the app.

The naming of "Push Notifications" and "Notifications" is ambiguous to many people.

Notifications (without the word Push)

Are defined by Android as

A notification is a message that Android displays outside your app's UI

This is what @FinnMarquardt is helping with in their answer - https://stackoverflow.com/a/58640641/887092

This can certainly even done without any network connection at all. When your app starts, you can display a notification like "The App just started". So this concept refers to a UI component that an App can use, and doesn't involve networking.

Push Notifcations

The word "Push" means a lot:

  • Channel - A specific communications channel that is managed by the OS vendor (Google); AND
  • Trigger - A trigger within the OS that wakes up your App
  • NOT a Notification (UI) - This mechanism doesn't display a Notification

The Channel is convenient because you don't need to built that (Protocol, and distribution Server(s)), but it is something you can build yourself.

  • For Android and FCM, a persistent TCP/IP connection is used - see https://developer.android.com/training/efficient-downloads/regular_updates.
  • For Apple APNs, it's the same, a persistent connection: https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/APNSOverview.html#//apple_ref/doc/uid/TP40008194-CH8-SW1. (Your cellphone carrier is not involved in any special way)
  • Therefore, having a single persistent shared connection per device is more (power) efficient than potentially having a connection per app on the device.

The Trigger aspect cannot be replicated. It's very important for the whole Smartphone in saving power. It allows apps to go to sleep, and let the OS take care of such a mechanism once for the whole smartphone. For Android, see https://developer.android.com/training/monitoring-device-state/doze-standby, and then take note of the section "Using FCM to interact with your app while the device is idle"

FCM high-priority messages let you reliably wake your app to access the network, even if the user’s device is in Doze or the app is in App Standby mode

The Doze mode of an app cannot wake itself up. You need an OS mechanism to do that, for Android that means a Push Notification (FCM).

A Push Notification mechanism on its own has nothing to do with "Notification" explained earlier. A "Push Notification" MAY trigger the app to display a "Notification", but not necessarily. For example, it might trigger the app which will then take a location (GPS) reading, and send that data to a server.

like image 181
Kind Contributor Avatar answered Oct 29 '22 20:10

Kind Contributor