[英]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.