andrius-k / Toast

Toast messages library for Xamarin.iOS
MIT License
41 stars 9 forks source link

Toast exception, not on UI Thread. #13

Closed jaybowman closed 4 years ago

jaybowman commented 4 years ago

I have a xamarin forms application with my shared code in a .net standard library project. I'm using an interface class to call the my IOS toast implementation from my shared project. I'm getting the following error: UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread Works fine in IOS simulator but throws the exception on physical device. Testing on device IOS version 13+ I guess I will try to wrap my interface calls in a run on UI thread block.

jaybowman commented 4 years ago

In my .net standard shared project i wrapped the interface calls with: MainThread.BeginInvokeOnMainThread(() => { // toast call. });

This fixed the exception.