CrossGeeks / GeofencePlugin

Geofence Plugin for Xamarin iOS and Android
MIT License
48 stars 22 forks source link

Would CrossGeofenceListener (IGeofenceListener) callbacks work on iOS if app is killed #12

Open asehgal123 opened 5 years ago

asehgal123 commented 5 years ago

I am using this plugin for Android and it working well except for the System.InvalidCastException: Specified cast is not valid. bug which someone provided the workaround for. My question is for iOS. If app is killed and a georegion is entered/exited would CrossGeofenceListener callbacks still be called?

patkozlowski commented 5 years ago

Yes, they do. In iOS, the geofencing API uses StartMonitoringSignificantLocationChanges which relaunches the app into the background if a new event arrives, IE a geofence event occurs. This is when the app is killed from memory too. You can read this. In Android, the provided service runs the geofencing triggers when the app is closed as well. In my testing, android 8 and above you have to use StartForgroundService instead of StartService, or else you'll get an exception due to google limiting starting services in the background.