Xamarin 跨地理围栏转换 [英] Xamarin CrossGeofence Transitions
问题描述
我在这里下载并安装了 xamarin 的 CrossGeofence 插件:https://github.com/domaven/xamarin-plugins/tree/master/Geofence
I downloaded and installed the CrossGeofence plugin for xamarin here: https://github.com/domaven/xamarin-plugins/tree/master/Geofence
使用此处找到的示例作为指导:https://github.com/domaven/xamarin-plugins/tree/master/样本/地理围栏
Used the sample found here as a guideline: https://github.com/domaven/xamarin-plugins/tree/master/Samples/Geofence
我一直在我的物理手机上测试它,LGE LG-D852 (Android 6.0 - API 23) 和 USB 调试.
And I've been testing it out on my physical phone, the LGE LG-D852 (Android 6.0 - API 23) with usb debugging.
我的 CrossGeofenceListener 类已经实现如:
My CrossGeofenceListener class has been implemented such as:
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 I've created and started monitoring fences such as:
foreach (var facility in Facilities)
{
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),
});
}
根据上述情况,我只会弹出输入的地理围栏通知.我没有收到退出并保持转换通知.关于如何触发停留和退出转换的任何建议?
With the above given, I am only getting the entered geofence notification popping up. I'm not getting the exit and stayed transition notifications. Any suggestions on how to get the stayed and exit transitions to trigger?
推荐答案
在与另一个应用程序欺骗 gps 坐标后,它已开始正确报告停留和退出通知.我唯一的假设是之前没有任何工作,因为 gps 坐标变化不够大.
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.
这篇关于Xamarin 跨地理围栏转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!