I try to reproduce the error in a small minimal solution, but I am unable to reproduce the issue. But I found the error where it is happening.
On Click of Login button in LoginPage, the following happens
private async Task OnLoginClicked()
{
AuthenticationCaller authenticationCaller = new AuthenticationCaller(this.Container);
if (authenticationCaller.LoginDevice())
{
AssignmentsDB assignmentsDB = new AssignmentsDB(this.Container);
await assignmentsDB.GetAssignmentsWithNavigation();
}
}
Inside GetAssignmentsWithNavigation function
public async Task GetAssignmentsWithNavigation()
{
await Task.Run(async () =>
{
DateTime date = DateTime.Now;
AssignmentCaller assignmentCaller = new AssignmentCaller(this.Container);
ObservableCollection<Assignment> entries = assignmentCaller.GetAssignmentsByDay(date);
await this.SqlLiteAssignmentActionLogInstance.RemoveActionLogsBeforeDay();
this.Assignments = entries;
await this.InsertAssignmentsHandler();
});
}
private async Task InsertAssignmentsHandler()
{
await Task.Run(async () =>
{
await this.InsertAssignmentsInSqlLite();
await this.InsertEarningRolesInSqlLite();
await this.AssignmentsNavigation();
});
}
private async Task AssignmentsNavigation()
{
await Shell.Current.GoToAsync($"//{nameof(AssignmentOrdersPage)}");
}
Error: UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread.
Maybe I am not handling the threading properly. In Android surprisingly it works. In IOS id doesn't work.