Realm Mobile Platform, How to Connect While Offline

realm mobile platform, how to connect while offline?

After you successfully log in (or register) the user it's cached in the device's keychain and you can retrieve it via currentUser property or alternatively if your app supports multiple users all even when you're offline.

Please note if you call logout on a user then it will be removed from the keychain and you will have to be online and log in again.

Realm use local db instead of sync when network connection is unavailable?

The way Realm Sync works is by ensuring that the copy of a Realm on your device and the copy of that same Realm on the server (and on any other devices) are always kept synchronized with each other. This means that you can use a synced Realm in exactly the same way as any other Realm even when there is no network connectivity at all. The synced Realm is the local Realm; you do not need to manually maintain two separate Realms containing the same data.

If you are offline when the app launches you can use the SyncUser.current API to get the previously logged-in user so you can open your synced Realms. (If you have logged in multiple users previously, you must use the SyncUser.all API instead to get a list of all the users and pick the one you want to use.)

Realm - offline use

In your initRealm() method, you include the following command:

Realm.deleteRealm(realmConfig);

In a nutshell, you delete your realm everytime you initialize it. This is why you get no results back. You don't need an internet connection to access your Realm. It is stored locally. You should just avoid deleting it.

Transparent login with the Realm Mobile Platform

Unfortunately you are correct: the very first time the user logs in to the Realm Object Server (via +[SyncUser logInWithCredentials:...]), the user needs to already have whatever identity provider account they're going to use (in your case, an iCloud account), as well as Internet connectivity.

Once the user's logged in at least once, their Realm credentials are persisted internally and the user can be used subsequently to open up Realms immediately, even if there is no connectivity.

The best workaround right now is to use a non-synced Realm to store whatever data you need before you have an opportunity to log in, and then manually copy the data over to your synchronized Realm once you are able to log in the user successfully and open the synced Realm with the user.

We know this is a pain point for a lot of our users, and plan to address this deficiency in the near future with features to let you immediately start using 'synced' Realms before a user has logged in.

How to manage sessions in Realm Mobile Platform?

Realm Mobile Platform doesn't support sharing the data between different users yet. Partially resolved by this PR https://github.com/realm/realm-cocoa/pull/4275.

So for now, you should share one SyncUser between multiple people to share session like a draw app demo.

Rdbms one way sync with Realm Object Server possible?

It's possible, but not in the freely available version of the Realm Mobile Platform on the Realm Website.

At the moment, only a sync-enabled version of the Realm Node.JS SDK is capable of opening and writing data to synchronized Realm files located on the server. This SDK is only presently available to people who have purchased the Enterprise edition of the Realm Mobile Platform. The developer edition of the Realm Mobile Platform only allows for modification of synchronized Realms from a user's local device.

A version of the Realm Mobile Platform with server-side integrations intended for indie level developers is also on its way. :)



Related Topics



Leave a reply



Submit