Realm Error Domain=io.realm.unknown Code=89 Operation canceled
The main issue is that you're mixing the existing Realm Sync documentation with the BETA MongoDB Realm Documentation - apparently a common issue.
The setup is different between the two and you cannot use the MongoDB Realm console to access your Realm Sync database - it can only be used with the BETA MongoDB Realm.
Here's the MongoDB Realm Sync docs noting that your objects need to have a partition key that matches the one set up on the console. Additionally, the connection sequence is different and looks more like this, including the partition and omitting fullSync (and others)
let user = app.currentUser()
let partitionValue = "myPartition"
Realm.asyncOpen(configuration: user.configuration(partitionValue: partitionValue),
The code in your question is for the 'classic' and current Realm Sync. You can access your Realm Sync with the Realm Studio app if you want to stick with the non-beta Realm.
Also note that working with objects is slightly different as well because you need to include the partition value for each object. For example, with MongoDB Realm, adding a task object would be this code
try! realm.write {
realm.add(Task(partition: partitionValue, name: "My task"))
}
Whereas, with classic Realm its just
try! realm.write {
realm.add(Task(name: "My task"))
}
can't open Realm using mongodb sync
As a complete guess, your config string is not correct
var configuration = user.configuration(partitionValue: "user=\(user.id)")
As that the partition value resolves to
partitionValue: user=Optional("5f1b586f757611faec257d88")
Try this
guard let user = your_app.currentUser() else {
print("no user")
return
}
guard let userId = user.id else {
print("no user")
return
}
var configuration = user.configuration(partitionValue: "user=\(userId)")
More to the point though, the partition value you're attempting to use is this string
user=5f1b586f757611faec257d88
and I think what you really want is use the user id
5f1b586f757611faec257d88
That's where I would start. If you're trying to leverage Realm rules, then something like _partitionKey: "team_id=1234"
would work but that goes beyond the scope of the original question (and adds another layer of complexity - get it working first, then explore the rules).
Related Topics
Cannot Invoke "+=" with an Argument List of Type (Int, @Value Int)
Swift Spritekit 3D Touch and Touches Moved
Self. in Trailing Swift Closures, Meaning and Purpose
Swiftui - Navigation View Opening with Back Button and Half Grey Screen/Weird Behavior
Can Openssl Be Bundled for Wget Wrapper App to Reference in Xcode Project
Realitykit - How to Add Motion to a Loaded Modelentity from Usdz File
How to Make a Function with a Loop Asynchronous in Swift
Compare Value from Two Struct in Swift
A Method Without Parameters Is Calling for an Argument
Iterate a Grid of Views Swiftui
How to Perform Conditional Segue
Nsurlsession Datataskwithrequest Not Being Called
Xcode Firebase | Cannot Convert Value of Type'Authdataresult' to Expected Argument Type 'User'
Sorting Several Arrays According to One Array
How to Procedurally Draw Rectangle/Lines in Swift Using Cgcontext