I’m developing ios app with Realm Cloud.
My app has multiple realm; one Common realm and many Private(per-user) realm.
I logged in realm server with specific user and tried to open another user’s Private realm following this method.
Code
// already logged in
let userIdentity = "fjwe3akj4d308fj2okljt439fwe127ahkf" // target user's identity
let realmURL = URL(string: "realms://myapp.us1.cloud.realm.io/\(userIdentity)/PrivateSyncRealm")!
let configPrivate = currentUser.configuration(realmURL: realmURL, fullSynchronization: true, enableSSLValidation: true, urlPrefix: nil)
Realm.asyncOpen(configuration: configPrivate) { realm, error in
if let realm = realm {
print("success")
let user = realm.objects(User.self).filter(String(format: "syncuserid == '%@'", userIdentity))
print(user[0])
} else if let error = error {
print("failed")
print(error)
}
}
I think that permission of the user could be a factor? (but don’t know how to modify)
Question
How to solve this error and get data from Private realm of another user.
Infomation
target realm: Sync - Full
logs: HTTP response: ◯◯◯◯◯◯ {"type":"https://docs.realm.io/server/troubleshoot/errors#access-denied","title":"The path is invalid or current user has no access.","status":403,"code":614}
If you’re going with MongoDB Realm (which you should be at this point). Go through the getting started guide Sync Data section to see how to connect up to MongoDB Realm and how to utilize partitions.
Once you do that, the code provided by Ian will make a lot more sense.
I may just be not looking at the question correctly.
@Shi_Miya Are you trying to open a realm that is private for the user doing the opening? If so, you can use the tilda - ~ - to automatically fill this in like so:
realms://myapp.us1.cloud.realm.io/~/PrivateSyncRealm
If you are trying to open another user’s realm then you need to grant permission to the user performing the open - see here: