CrossGeeks / GeofencePlugin

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

RequestState & DidDetermineState Sometimes Doesn't Get Called on iOS #8

Closed patkozlowski closed 5 years ago

patkozlowski commented 5 years ago

I see why they put a delay timer directly after requesting the state per the stackoverflow link, but still sometimes, RequestState & DidDetermineState doesn't get called. Anyway to remedy this any further, or even give a way to detect RequestState & diddeterminestate doesn't fire (through GPS strength, etc). Seems to happen too when the geofences are saved (persistant) when you launch the app. Has anyone encountered this?

  locationManager.StartMonitoring(cRegion);
// Request state for this region, putting request behind a timer per thread: 
   Task.Run(async () => {
        await Task.Delay(TimeSpan.FromSeconds(2));
        locationManager.RequestState(cRegion);
    });
patkozlowski commented 5 years ago

Marking this as closed. Turns out an AdBlocking app was highjacking location request for some odd reason, and the Geofence would not start about 10% of the time, and RequestState was not called. Make sure any adblocking VPNs, especially on iOS is turned off for this to work properly.

Also, to add on to this. I've eliminated the hardcoded 2-second delay by requesting the state in DidStartMonitoring for a region by the first response of this. Of course the 2-second delay works, but I think this is a better way to remedy.

     void DidStartMonitoringForRegion(object sender, CLRegionEventArgs e)
    {
         locationManager.RequestState(e.Region);
         CrossGeofence.GeofenceListener.OnMonitoringStarted(e.Region.Identifier);
    }