Reputation: 1037
Is there an architecture that exists that could help me with something like this.
I'm working on a react-native app which allows people to optin, theres mechanisms for users to optout and while the app is in the background it will automatically optout users depending on the circumstances - [idle etc]
the problem arises when someone shutsdown/closes the app after optin. This leaves them as active on my server and confuses other users.
My nodeserver is current running on AWS. Would it be quite server intensive to have optin users ping a lambda or something similar and if pings stop, i can mark them as opted out ?
Alternatively https://facebook.github.io/react-native/docs/appstate I can detect when the app state is inactive [because inactive state is the state you need to be in to shutdown the app - ios anyway] after this - app state either resolves to foreground/background.
Inactive to ping the server which will then wait for another ping from background/foreground and if thats not received, it can opt out the user?
Upvotes: 1
Views: 243
Reputation: 354
The first thing that comes to mind is like a heart beat signal sent with a frequency that doesn't impact the performance of your app. If the heartbeat doesn't come in the set time then you know that user is not available. I thinks that's how they do it on most messaging apps. I know you probably already tried to add a log out action in componentWillUnmount() probably in your root component.
Upvotes: 1