Reputation: 105
I'm working on an app that is very simple (it's a chat app)
I have a server and Android users.
for example say we have 2 users, user_a and user_b. user_a enters a chat room and sends "hi user_b" (user_b is registered to this chat room) when user_a sends his message, it is also sent to the server.
I'd like to make a service that will be running always in the background even when the app isn't running. that service will check for new updates each time.
so I'd like user_b to receive the message, and it will appear as notification.
in order to do it my approach is to make a service that will continuesly run in the background. any suggestions?
Upvotes: 0
Views: 195
Reputation: 413
The best way to do this is sending messages to your server, which will notify recipients via GCM in real-time. You need to create a gcm intent service so you can catch gcm messages and handle them properly in your app (build a notification and updating chat activity) You can also broadcast the messages you receive from gcm notifications so you update your chat online (like all chat apps do…) I recommend you to read about GCM and broadcast
Upvotes: 2