SpiralDev
SpiralDev

Reputation: 7321

Check if android device is online from server

I have a script on server which sends sms or telegram messages to users. I want to send sms when user is offline and send telegram message when user is online.

Is there any way to detect whether android user is online or not from my server (maybe sending request to already running some app?).

Note, users are willing to share some credentials if necessary.

Android OS version: Api 21+

Upvotes: 1

Views: 1841

Answers (1)

SpiralDev
SpiralDev

Reputation: 7321

Well, I created my own app.:

  1. I used firebase cloud messaging to send notification (as it is lightweight and based on event-driven model) to devices from my app server. Byw, telegram uses gcm which is younger brother of fcm.
  2. I send only data messages (only payload) to my app from my app server so that I can get my app notified about notifications even if it is in background.

  3. When app receives notification, it sends upstream message so server knows that user has received message.

  4. If server doesn't receive response from user within 5-10 seconds, then user is most likely to be offline.

Upvotes: 3

Related Questions