Hi folks,
In my app I’m trying to use ‘@AutoOpen’ because I want to offer offline access to data after an initial sync. I’m specifically choosing ‘@AutoOpen’ because I don’t want to block the user on syncing first if they are offline, I want this behavior to try to open, but time out and use offline mode if the user can’t login again.
However, I’m not sure how to use the Realm.Configuration in each of these scenarios and get the data in both cases.
Here’s what I have working:
if let user = app.currentUser {
config = user.configuration(partitionValue: "")
}
... then later on...
.environment(\.realmConfiguration, config)
When my app is online, my data from Atlas syncs up great, no problem.
What should I do if my app is offline? I tried using .defaultConfiguration
instead, but this opens up an empty Realm instance with no data in it. I want to still access my existing data from before. Please advise?