[英]geofencing for multiple region for xamarin ios
我需要在我的应用中输入和退出通知。 所以我写下了相同的代码,它按预期工作。 但我想检查多个叠加或区域。
例如,我有3个叠加或具有特定坐标的区域。 我想检查用户当前位置附近区域的进入和退出。
if (pointregion.ContainsCoordinate(location.Coordinate) && Entryregion == false)
{
Entryregion = true; Exitregion = false;
ShowNotification("You are just in " + pointregionname + " region", "Alert");
}
if (!pointregion.ContainsCoordinate(location.Coordinate) && Entryregion == true)
{
Entryregion = false; Exitregion = true;
ShowNotification("You are just left " + pointregionname + " region", "Alert");
}
您应该使用CLLocationManager
的区域监控并设置地理围栏区域。
创建CLCircularRegion
或其他CLRegion
类型的列表。
通过为每个区域调用locationManager.StartMonitoring(yourRegion)
来添加所有区域。
完成特定区域后,通过调用locationManager.StopMonitoring(yourRegion)
将其删除
然后,当一个区域进入或离开RegionLeft(CLLocationManager manager, CLRegion region)
或RegionEntered(CLLocationManager manager, CLRegion region)
将调用委托方法。 您需要在CLLocationManagerDelegate
类中重写这些方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.