private GeofenceMonitor() { #if __UNIFIED__ _locationManager = new CLLocationManager(); _locationManager.DesiredAccuracy = CLLocation.AccuracyBest; _locationManager.AuthorizationChanged += _locationManager_AuthorizationChanged; _locationManager.LocationsUpdated += _locationManager_LocationsUpdated; #if __IOS__ _locationManager.AllowsBackgroundLocationUpdates = true; UIApplication.SharedApplication.BeginInvokeOnMainThread(() => { _locationManager.RequestAlwaysAuthorization(); }); if (!CLLocationManager.IsMonitoringAvailable(typeof(CLCircularRegion))) #else if (!CLLocationManager.IsMonitoringAvailable(new ObjCRuntime.Class("CLCircularRegion"))) #endif { Status = GeofenceMonitorStatus.NotAvailable; } else { maxRegion = _locationManager.MaximumRegionMonitoringDistance; _locationManager.RegionEntered += _locationManager_RegionEntered; _locationManager.RegionLeft += _locationManager_RegionLeft; } #elif WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE _monitor = Windows.Devices.Geolocation.Geofencing.GeofenceMonitor.Current; #elif TIZEN _locator = new Tizen.Location.Locator(Tizen.Location.LocationType.Hybrid); _locator.ZoneChanged += _locator_ZoneChanged; _locator.ServiceStateChanged += _locator_ServiceStateChanged; #endif }
void GeofenceStateChanged(Windows.Devices.Geolocation.Geofencing.GeofenceMonitor sender, object args) { //sender.Geofences }