I’m just trying to access a global Realm file which is on my Realm Cloud (I am NOT on the beta). I get the “Operation canceled” Realm Error Domain=io.realm.unknown Code=89
error when I try to open the Realm.
Realm Studio:
Opening code:
let url = URL(string: "realms://\(MY_INSTANCE_ADDRESS)/common")!
let config = user.configuration(realmURL: url, fullSynchronization: true)
Realm.asyncOpen(configuration: config) { ... }
Authentication code (using PromiseKit):
private func connectToRealm(_ firebaseUser: User) -> Promise<SyncUser> {
// if realm user already logged in, check if it's the right user
if let user = SyncUser.current {
guard user.identity == firebaseUser.uid else {
// it's not the right user. log out and try again.
user.logOut()
return connectToRealm(firebaseUser)
}
// it's the right user.
return Promise.value(user)
}
return firstly {
// get JWT token with firebase function
Promise {
Functions.functions().httpsCallable("myAuthFunction").call(completion: $0.resolve)
}
}
.compactMap { result in
// extract JWT token from response
return (result?.data as? [String: Any])?["token"] as? String
}
.then { token in
// connect to Realm
Promise {
SyncUser.logIn(with: SyncCredentials.jwt(token), server:MY_AUTH_URL, onCompletion: $0.resolve)
}
}
}
This method is called after logging with Firebase. The auth URL is just https://\(MY_INSTANCE_ADDRESS)
.
I suspect it’s a permission problem, in which case: how can I easily let this file be readable by everyone, but not writable? I’m not planning on creating a lot of theses files, I just want to do this once.