Transparent login with Realm mobile platform

I am moving an app using CloudKit sync to use the Realm Mobile platform.

I want the registration process to be transparent to the user, so I use CloudKit authentication so they don't have to worry about creating an account or remembering a password. Of course, if the user does not have an iCloud account, the data is not synced, but the way the application already works without the scope: we just warn the user that the data is not syncing because the iCloud account could not be found.

I noticed in the documentation that in order to open the synced pane, I have to provide user credentials.

My question is, how do I handle the case that the first time the user launches the app, they have no internet connection or no iCloud account? I'd like to just store the data locally if the user doesn't have an iCloud account (this is how the app currently works), but if I understand it correctly, the only way to open the synchronous realm is to force the user to credentials for which I need internet access , and the iCloud account that will be configured on the device to receive. Is there an easy way to deal with this case using scope?

I know that I can have a separate offline storage and move its data to the synced realm once online, but it would be difficult to get it right and quite a lot of work.

+3


source to share


1 answer


Sorry, you're right: the first time a user logs into the Realm Object Server (via +[SyncUser logInWithCredentials:...]

), the user must already have any identity provider account they will use (in your case iCloud), as well as an internet connection.

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



The best workaround right now is to use an unsynchronized kingdom to store any data you need before you have the ability to log in, then manually copy the data to your synced kingdom as soon as you can login successfully and open the synced realm with user.

We know this is a sore point for many of our users, and plan to address this shortcoming in the near future with features that allow you to start using "synced" areas right away prior to user login.

+1


source







All Articles