Realm Swift 3.6
I have an Realm platform based application with two realms. One is the standard user realm and the second is a read only realm that is shared across users. After the user logs in for the first time, the shared realm is fully synced (and always opened via asyncOpen as described in the docs) to the device before the user is allowed to continue any further into the app. From this point onward, the data within the shared read-only realm is accessible and the application works as desired as long as the user remains online or the app does not close. However, as this is unrealistic to expect, I have tried a range of different situations and here are my results:
- If the user is online and the app is started up from a closed state (either after having been closed due to to inactivity or killed by the user) everything works as expected and the shared data is available.
- If the app has not been closed and the user goes offline, all the shared data is accessible.
- As soon as the user goes offline and tries to start up the application from a fully closed state (again I am using asyncOpen behind the scenes), the shared data is completely missing, but it will become accessible when the app is brought back online either from a closed state or while the app in open.
- If I make the shared realm read/write, all these problems go away.
- If I build directly to a device via Xcode, run the app while online, close it and then build again to the same device that has now been taken off line, even through the app is offline the shared data is accessible. I can kill the app and open it as many times as I want while it is off line and the shared data will always be there. However, as soon as that build is brought online (shared data is visible still), killed and then opened again when off-line, the shared at a is again gone.
This use of shared read only data seems to be a pretty simple and I would think standard use case. Fundamentally, I would expect the data in the shared realm to be available on the device even if the user is offline and even if it is read only data. While one potential solution is to make the data read write, I don’t like this approach because any user with a malicious streak could log into the serve using their own credentials and delete all the data. I have also read that partial sync might be a possible solution, but given the fact that I want the user to have the full copy fo the shared data on their local device at all times, a full synced realm seems the correct approach.
Am I missing something here or is there a bg in how the synced realms that are read only work?