简体   繁体   中英

Server as Service in background for Android?

I have a notification hanler which manages to notify the user by means of various ways (Snachbar, NotificationManager).

I would like to enhance this functionality by adding a service to that notification manager, which runs always in the background and waits/listens for notifications from the back-end.

When I trigger a message from my back-end like "Please update your app from PlayStore" it should be shown to the user. (I know how to do this, when I trigger that from the mobile by a REST call to my endpoint.) But I don't know, if it is possible to listen (on a port or something) as a server?

Supposing you already have a server able to send notifications/messages, the best way to receive notifications/messages on an Android phone is to implement Firebase Cloud Messaging.

You will have to create a Firebase project here

It is Google's official way to implement what you want to do. The Firebase Documentation is really well done and easy to understand.

You must have a end-point that it will return boolean value. The app is first run when you check the end-point. İf it's true then you'll show a dialog "Please update your app from PlayStore"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM