2

We are developing an instant messaging App, and would need to display the "presence" of user's friends with a green dot on their avatars.

"Presence" goes far beyond "my_app_is_opened_and_on_focus", it means (and I guess one could have many definitions of "presence"): user has been using his device to do anything (even just checking time) during the last 2 or 5 minutes.

Any idea on how could we get this "presence" or "generic recent activity" information and log it on our server even if our app is closed? (on iOS and Android)

Jérôme
  • 75
  • 2

1 Answers1

0

You can create a service running in the background to check the screen status.

For Android: Use BroadcastReceiver for these actions.

android.intent.action.SCREEN_OFF
android.intent.action.SCREEN_ON

when receiving SCREEN_ON or SCREEN_OFF send a small message to the server to track the activity of the user.

Kh5
  • 167
  • 2
  • 10