I am working on an app that relies heavily on detecting when users go offline and go back online. I wanted to do this with AWS AppSync, but I can't seem to find a way to do this in the documentation. Is there a way to do it in AppSync?
1 Answers
Thanks for the question. Detecting presence is not currently support out of the box but you can likely build similar features yourself depending on the use case.
For example, a resolver on a subscription field is invoked every time a new device tries to open a subscription. You can use this resolver field to update some data source to tell the rest of your system that some user is currently subscribed. If using something like DynamoDB, you can use a TTL field to have records automatically removed after a certain amount of time and then require a user to "ping" every N minutes to specify that they are still online.
You could also have your application call a mutation when it first starts to register the user as online, then have the application call another mutation when the app closes to register it as offline. You could combine this with TTLs to prevent stale records in situations where the app crashes or something prevents the call to register as offline.
Thanks for the suggestion and hope this helps in the meantime.

- 3,623
- 1
- 17
- 16
-
By any chance do you know if this feature was included yet? I do not see it, but I am really hoping I am wrong. My app heavily relies on that and the answer you suggested 6 months ago doesn't fully meet my needs. Thanks! – Rookie Jun 06 '20 at 13:04
-
@mparis can we somehow integrate Socket.io to do the job?. I am new to AWS, I really did not get your explanation. – Balaji Venkatraman Oct 02 '21 at 05:02
-
Potential solution as of November 2021: https://aws.amazon.com/blogs/gametech/building-a-presence-api-using-aws-appsync-aws-lambda-amazon-elasticache-and-amazon-eventbridge/ – Rookie Nov 07 '21 at 01:30