domaven / xamarin-plugins

Cross platform Xamarin & Windows plugins for PCLs
MIT License
37 stars 51 forks source link

(iOS) Fix KeyNotFoundException during CheckIfStayed #6

Closed streaming closed 8 years ago

streaming commented 8 years ago

Hey,

We have noticed this exception occurring in our application that relies on NotifyOnStay but also changes the geofences being monitored fairly often (via StopMonitoringAllRegions -> StartMonitoring with the new geofence set) every 30minutes or so.

System.Collections.Generic.KeyNotFoundExceptionThe given key was not present in the dictionary. System.ThrowHelper.ThrowKeyNotFoundException() System.Collections.Generic.Dictionary<TKey, TValue>.get_Item(TKey key) Geofence.Plugin.GeofenceImplementation.d__30.MoveNext()

This is just a small tweak to ensure that the region still exists in the internal dictionaries before accessing them after the Task.Delay so that the KeyNotFoundException isn't thrown.

Thanks!