Upgrading a Default Realm to a Synced Realm and Vice Versa

My application uses a freemium model, wherein free users can interact with the application locally without an account.

Currently data is stored in local files on-device.

I would like to migrate these local files to default Realm, and use Realm for persistence.

I would then like to offer the ability to backup & synchronize data for paying users of my application. However, this requires using “Sign in With Apple” in my case to authenticate them, and allow me to create a persistent, synced Realm.

However, a user can “Stop using Apple ID” with my application via Settings, which effectively signs them out. Alternatively, their subscription could lapse, in which case they should no longer be able to sync their data, and revert to local-only modifications.

This model is predicated on my ability to open a default Realm, operate within it, then convert it to a synced Realm, and at any point, stop syncing and revert back to a local-only Realm, much like the default Realm.

Is this possible? I’m trying to figure it out from the docs and from my own sample apps but I’m coming up short on conclusive answers.

The only other solution I could think of is to manually copy all objects from one realm to another and back whenever the user “upgrades” or “downgrades”, but oof, that sounds scary.

In my case, once a subscription lapses or an account is disabled, then the app should behave as if it doesn’t have a network connection, and all operations are local-only, unless the user renews their subscription or re-links the app, in which case changes are synced back up to the server.

Your proposed solution is the one we would recommend - you will need to copy data between sync and non-sync realms. That is the only option right now.

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