domaven / xamarin-plugins

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

CrossGeofence plugin not triggering stayed transition. #12

Closed NebriBlackwing closed 8 years ago

NebriBlackwing commented 8 years ago

Implemented my CrossGeofenceListener as such from the sample as a guideline:

` public class CrossGeofenceListener : IGeofenceListener { //TODO: figure out what to do with this one. public void OnAppStarted() { //throw new NotImplementedException(); }

//copied from geofence sample
public void OnError(string error)
{
    Debug.WriteLine(string.Format("{0} - {1}: {2}", CrossGeofence.Id, "Error", error));
}

//TODO: figure out what needs to be done when the location changes.
public void OnLocationChanged(GeofenceLocation location)
{
    //throw new NotImplementedException();
}

//copied from geofence sample
public void OnMonitoringStarted(string region)
{
    Debug.WriteLine(string.Format("{0} - {1}: {2}", CrossGeofence.Id, "Monitoring in region", region));
}

//copied from geofence sample
public void OnMonitoringStopped()
{
    Debug.WriteLine(string.Format("{0} - {1}", CrossGeofence.Id, "Monitoring stopped for all regions"));            
}

//copied from geofence sample
public void OnMonitoringStopped(string identifier)
{
    Debug.WriteLine(string.Format("{0} - {1}: {2}", CrossGeofence.Id, "Monitoring stopped in region", identifier));            
}

//copied from geofence sample
public void OnRegionStateChanged(GeofenceResult result)
{            
    Debug.WriteLine(string.Format("{0} - {1}", CrossGeofence.Id, result.ToString()));
}

}`

and used this to start monitoring areas:

CrossGeofence.Current.StartMonitoring(new GeofenceCircularRegion(facility.Name, facility.Latitude, facility.Longitude, 2000) { NotifyOnStay = true, NotifyOnEntry = true, NotifyOnExit = true, ShowNotification = true, ShowEntryNotification = false, ShowExitNotification = false, ShowStayNotification = true, NotificationStayMessage = "stay message!", NotificationEntryMessage = "entry message!", NotificationExitMessage = "exit message!", StayedInThresholdDuration = TimeSpan.FromSeconds(1), });

Using my tests on my phone, I am only getting the entered Geofence notification, the stayed notification is not triggering.

Have I missed something?

NebriBlackwing commented 8 years ago

I'd also like to note that the sample application shows the exact same problem unmodified on my phone.

NebriBlackwing commented 8 years ago

After spoofing the gps co-ordinates with another app it has started reporting the stay and exit notifications correctly. My only assumption is that nothing was working before due to the gps cordinates not changing drastically enough.