I need to keep track of devices that are actively running the app. Right now I have a status field that changes to 1 when the app is first launched or when the device becomes active. When the user presses the home button, I set the status field to 0 upon receiving the notification UIApplicationWillResignActiveNotification
if(self.device) {
[self.realm transactionWithBlock:^{
self.device.status = 0;
}];
}
self.device = nil;
[self.realm refresh];
However, I check the data in Realm Cloud, and it doesn't seem to be updating at all. Is there some way to force update the sync of my Realm data?
If you want to achieve this by only using the realm platform
, I think you should implement a status updating logic. For example, every 5 seconds, a client should update a value. It can be the current timestamp, and you can detect online users by looking at the the last timestamp value.
In my opinion, a simple socket.io implementation can be a better solution. You can save users’ connection status by saving them in the socket server. You need to save the timestamp when the client connects to the server and when they disconnect.
I believe you can do the same with ROS
, but I'm not sure they provide a public API for user connection events or status.