Android push notification without Google service

2019-04-09 08:20发布

问题:

I am from Apple world, so I don't have much experience with Android.

But what I am looking is a way that Android devices receive push notification, without using any third party servers. Notification need to be standard Android notification (look and feel)

The reason I need this is, because I would need this in a room that does not have access to outer world. (can't connect to any server) But I have my own WiFi so users can receive push notification from my server via my wifi.

I know that on iOS this is not possible, what about Android?

回答1:

it is possible using Service left running in system (background) after app exit. some samples HERE, you should be interested in START_STICKY flag

you have to keep some connection (socket?) or interval requesting (not so well, but possible) inside your Service. Google Services (including Firebase) does that by itself and "redeliver" received push messages to properly declared (in manifest) app