Hi everyone!
I’m trying to use Realm sync with Realm .NET v10.10.0(Xamarin).
When I’m running the app I get below error,
Realms.Exceptions.RealmException: ‘A system error occurred while opening a Realm. See InnerException for more details.’
And here is the log event.
My Schema,
{
"bsonType": "object",
"properties": {
"Amount": {
"bsonType": "double"
},
"CustomerDetails": {
"bsonType": "object",
"properties": {
"Name": {
"bsonType": "string"
},
"Telephone": {
"bsonType": "int"
}
}
},
"Date": {
"bsonType": "date"
},
"Description": {
"bsonType": "string"
},
"Gms": {
"bsonType": "int"
},
"InvoiceNO": {
"bsonType": "string"
},
"ItemNo": {
"bsonType": "string"
},
"Mg": {
"bsonType": "int"
},
"TotalAmount": {
"bsonType": "double"
},
"_id": {
"bsonType": "objectId"
},
"_partition": {
"bsonType": "string"
},
"UserID": {
"bsonType": "string"
}
},
"required": [
"_id",
"_partition",
"UserID"
],
"title": "Item"
}
My Model
public class Item : RealmObject
{
[PrimaryKey]
[MapTo("_id")]
public ObjectId Id { get; set; }
public double Amount { get; set; }
public CustomerDetails CustomerDetails { get; set; }
public DateTimeOffset? Date { get; set; }
public string Description { get; set; }
public int Gms { get; set; }
public string InvoiceNO { get; set; }
public string ItemNo { get; set; }
public int Mg { get; set; }
public double TotalAmount { get; set; }
[MapTo("_partition")]
[Required]
public string Partition { get; set; }
[Required]
public string UserID { get; set; }
}
Method for Realm activity
private async void RealmSync()
{
var app = Realms.Sync.App.Create("_app-id");
var user = await app.LogInAsync(Credentials.EmailPassword("emai@email", "password"));
//var user = await app.LogInAsync(Credentials.Anonymous());
var config = new PartitionSyncConfiguration("_partition", user);
var realm = await Realm.GetInstanceAsync(config);
//await realm.GetSession().WaitForDownloadAsync();
realm.Write(() =>
{
realm.Add(new Item()
{
Id = new ObjectId(),
ItemNo = "K-450",
Description = "Nice description",
Gms = 5,
Mg = 9,
Amount = 10000,
TotalAmount = 120000,
CustomerDetails = new CustomerDetails
{
Name = "A B C Name",
Telephone = 1234567890
},
InvoiceNO = "C12345",
Date = DateTime.Now,
Partition = "_partition",
UserID = "62306e3ac00255a71fc2f5dd"
});
});
}
Permitions used in sync
Please can you tell me what’s I’m doing wrong?
Thank you!