public async Task Stop() { MvxTrace.TaggedTrace(MvxTraceLevel.Error, "Geofencing", "Stop"); var result = await GeofencingUtil.RequestPermissionAsync(); if (result) { GeofencingProvider.UpdateRegionLeft -= OnUpdateRegionLeft; GeofencingProvider.RegionEntered -= OnRegionEntered; GeofencingProvider.SetRegions(new System.Collections.Generic.List <CoreLocation.CLCircularRegion>()); } }
protected virtual async Task SetupRegions() { var location = await GeofencingUtil.GetCurrentLocationAsync(); try { MvxTrace.TaggedTrace(MvxTraceLevel.Diagnostic, "Geofencing", "Setup regions"); var response = await AreaService.Instance.LoadAreasByUserLocation(location.Coordinate.Latitude, location.Coordinate.Longitude); var geofencingRegions = response.Select(area => GeofencingProvider.CreateRegion(area.Latitude, area.Longitude, area.Radius, area.ID)) .ToList(); var updateRegion = GeofencingProvider.CreateUpdateRegion(location.Coordinate.Latitude, location.Coordinate.Longitude, _updateRadius); GeofencingProvider.SetRegions(geofencingRegions, updateRegion); } catch (Exception ex) { MvxTrace.TaggedTrace(MvxTraceLevel.Error, "Geofencing", ex.BuildAllMessagesAndStackTrace()); } }