Flexible-sync and offline device best practice

Hi there,
i’ve tried flexible-sync with success but i wonder if is it possible also to manage offline realm. In my application i want the users to share a realm but they can work also offline and the sync when on line. What’s the best practice to do that? Am i supposed to mange two different realms, one with flexible-sync and the other only on local device?

Thank’s in advance.

You can still use the synchronized realm file while offline. The whole idea of Realm is to allow you to work with your database and not worry about connectivity.

Thank you @nirinchev,
so i use the same connection without worrying about the device is online or offline?
Anyway thank’s, i’ll try :wink:

Hi @Gianluca_Suzzi,

Most of the time, yes, disconnections, especially in a mobile environment, will happen, but Realm will work regardless on the local data, and pick up where it left when the connection is back.

The only case you’ll have to avoid is to change the subscriptions (i.e. the criteria you select data to keep on-device) while offline: as you can’t contact the backend, the attempt to re-sync following a change in subscriptions will fail.

And to clarify there, you can definitely change the subscriptions while offline, but the effect of that change will only become apparent when the device becomes online. The change will be persisted though, so even if you restart the app, it will eventually go through.

1 Like

Thank you for your support guys :wink:

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.