簡體   English   中英

xamarin ios的多個區域的地理圍欄

[英]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");
            }

您應該使用CLLocation​Manager的區域監控並設置地理圍欄區域。

  1. 創建CLCircularRegion或其他CLRegion類型的列表。

  2. 通過為每個區域調用locationManager.StartMonitoring(yourRegion)來添加所有區域。

  3. 完成特定區域后,通過調用locationManager.StopMonitoring(yourRegion)將其刪除

然后,當一個區域進入或離開RegionLeft(CLLocationManager manager, CLRegion region)RegionEntered(CLLocationManager manager, CLRegion region)將調用委托方法。 您需要在CLLocationManagerDelegate類中重寫這些方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM