I can't open a Realm. There is something wrong with my set up. This is the code in the app:
var configuration = user.configuration(partitionValue: "user=\(user.id)")
configuration.objectTypes = [User.self]
Realm.asyncOpen(configuration: configuration) { [weak self](userRealm, error) in
self!.setLoading(false);
guard error == nil else {
fatalError("Failed to open realm: \(error!)"). ///// here was my error before the edit (I changed the Permission Settings in Sync)
}
Error code: "Fatal error: Failed to open realm: Error Domain=io.realm.unknown Code=89 "Operation canceled" UserInfo={Category=realm.basic_system, NSLocalizedDescription=Operation canceled, Error Code=89"
Screenshot of Mongodb Sync configuration
EDIT: Replaced the Permission settings in Sync with the ones mentioned in the Task Tracker app and that got it connected:
EDIT: the configuration settings were changed to the below as per the suggestions from Jay.
var configuration = user.configuration(partitionValue: "\(currentUser.id!)")
Here is my Scheme definition for the User Collection:
{
"properties": {
"_id": {
"bsonType": "string"
},
"_partition": {
"bsonType": "string"
},
"name": {
"bsonType": "string"
}
},
"required": [
"_id",
"_partition",
"name"
],
"title": "User"
}
This is my User class in Xcode:
class User: Object {
@objc dynamic var _id: String = ""
@objc dynamic var _partition: String = ""
@objc dynamic var name: String = ""
override static func primaryKey() -> String? {
return "_id"
}
}
EDIT: I got this going to establish a connection by updating the Sync Permissions, so the app does not crash any more. However, now I am getting this message:
Connection to daemon was invalidated
Signup successful!
Log in as user: y
Login succeeded!
2020-10-25...Sync: Connection[1]: Session[1]: client_reset_config = false, Realm exists = false, async open = false, client reset = falseSync: Connection[1]: Session[1]: client_reset_config = false, Realm exists = false, async open = false, client reset = false
2020-10-25...Sync: Connection[1]: Connected to endpoint '13.54.209.90:443' (from '.....:52139')
2020-10-25...Sync: Connection[1]: Reading failed: End of input
2020-10-25...Sync: Connection[1]: Connection closed due to error```
I don't understand that the error "("Failed to open realm: (error!)")" in my above code is not triggered, but then in the log it says that the realm does not exist! So, what's going on here?
EDIT : this is the user table in mongodb, so I created some Users successfully.
EDIT : This is the log from mongodb
As we can see the User Id and the Request ID are not the same! I guess that the two IDs should be the same string in order to be authenticated, right??
I am following the Task Tracker app tutorial from the mongodb webpage for Swift to add the user login to my app. What am I missing here?



