Track app running in background

Hello!

Is there a way to track the app running in the background? For our app, we want to track users who are active or not when they log in. If the user never logs out, we want to track if they are active within the app itself. I found the section in AppGyver’s documentation on Device sensors, but I am not sure if those are useful or not to track user activity.

To clear it up, we want to update if the user is online every 10 minutes. Is there a sort of timer we could use to track that?