在使用信標(iOS設備)進行測試時,我發現監聽器信標給出了一些意外的行爲。 locationManager:didEnterRegion即使信標進入區域,方法也不會被調用。但locationManager:didRangeBeacons:inRegion:正在調用正確,並且在那裏顯示檢測到的信標。有沒有人經歷過這樣的事情?locationManager:當檢測到信標時不會調用didEnterRegion
回答
很難說如果我沒有看到完全相同的東西,沒有關於測試開始條件的更多細節。但是,是的,在某些特定情況下,我看到了locationManager:didRangeBeacons:inRegion即使沒有調用locationManager:didEnterRegion也會被調用。
如果您在同一地區同時開始測距和監控,並且iOS認爲您在已在處於受監控的地區,那麼您可能無法調用locationManager:didEnterRegion。
要真正測試,如果有什麼不妥,你需要建立一個測試用例,你:
- 確保你是不是在該地區。
- 讓iOS的幾分鐘運行
- 開始監視區域
- 讓iOS的繼續幾分鐘
- 輸入區域運行。
- 看看你得到的LocationManager一個電話:didEnterRegion
如果你還是不通過上面的準備後接到一個電話,然後東西肯定是不對的。
我進入該地區後開始傳輸。在這種情況下,它應該叫..對嗎?一旦我通過停止發送而退出該區域,然後我再次開始發送,它的工作就像被感知(didEnterRegion被調用)。 –
*你*認爲你進入該地區並不重要。 :)所有重要的是iOS LocationManager認爲的事情,它的當前狀態對你來說是不可見的。您需要100%確定它不認爲它已經在您開始監控時定義的區域中,因爲如果它認爲它已經在區域中,則可能無法獲得回撥。這就是爲什麼我建議上述程序 - 它確保iOS在測試開始時將您識別爲在區域之外。 – davidgyoung
讓我以另一種方式提出這個問題......如果您報告的問題是可重複的,那麼您在評論中所說的內容與您所說的內容在原始文章中無效之間有什麼區別?你重新啓動你的手機嗎?你等了很長時間嗎?重複失敗需要什麼? – davidgyoung
檢查您的方法是否按照以下方式實施。 在viewDidLoad
,開始在端
self.beaconRegion.notifyOnEntry=YES;
self.beaconRegion.notifyOnExit=YES;
self.beaconRegion.notifyEntryStateOnDisplay=YES;
[self.locationManager startMonitoringForRegion:self.beaconRegion];
監測開始後moniotoring,請求狀態爲您的限定區域
- (void) locationManager:(CLLocationManager *)manager didStartMonitoringForRegion:(CLRegion *)region
{
[self.locationManager requestStateForRegion:self.beaconRegion];
}
確定狀態後,開始測距信標
-(void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
{
if (state == CLRegionStateInside)
{
//Start Ranging
[manager startRangingBeaconsInRegion:self.beaconRegion];
}
else
{
//Stop Ranging here
}
}
和實施以下方法根據您的需要...
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
[email protected]"Entered region";
}
-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
{
[email protected]"Exited region";
}
-(void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region
{
if(beacons.count>0)
{}
}
希望這能解決您的問題。
before starting coding in project , you must follow given setup guidlines -->
1. in project info or info.plist -->
Custom IOS Target Properties -->
. add "Required background modes"
. in this add two items -->
."App shares data using CoreBluetooth"
."App registers for location updates"
2. in project Capability -->
There is Background Modes
. check "Loaction update"
. check "Acts as a Bluetooth LE accessory"
. check "uses bluetooth LE accessories"
(和不遵循Davidgyoung先生的指示相信我,這肯定會工作。)
好答案。爲我工作.. –
如果您的應用程序是BLE中心,則需要在所需的背景模式下設置「使用CoreBluetooth進行應用程序通信」。如果您的應用程序是BLE外設,您需要設置「使用CoreBluetooth的應用程序共享數據」 – mezulu
您還需要了解你正在監視區域 - 不是特定信標。
所以,如果你有3個信號燈共享相同proximityUUID
和您所在的區域被定義爲僅proximityUUID
(不包括主要和次要值),您將得到只有在兩種情況下通知:從
無標區域是在範圍和第一個信標/信標被 發現(
從區域didEnterRegion:
)一個或多個信標是在範圍內,他們都出去的視線 〜30秒(
didExitRegion:
)
這對我有幫助。謝謝。 –
- 1. LocationManager didEnterRegion沒有被調用(再次)
- 2. 沒有調用過LocationManager的didEnterRegion
- 3. didEnterRegion方法不會調用實際的信標設備
- 4. startMonitoringForRegion永遠不會調用didEnterRegion/didExitRegion
- 5. iOS Geofencing不會調用'didEnterRegion',didExitRegion,'didStartMonitoringForRegion'
- 6. AltBeacon庫BootstrapNotifier不會調用didEnterRegion
- 7. 當應用程序關閉時AltBeacon未檢測到信標
- 8. 當Nuance Dragon被調用時檢測到
- 9. 當兩個locationManager對象調用requestLocationUpdates(...)時?
- 10. didEnterRegion和startRangingForBeacons不被調用
- 11. 對於某些iPhone,僅在屏幕打開後纔會調用信標didenterregion
- 12. 當檢測到信標時打開一個新的視圖
- 13. 當用戶會話超時時檢測
- 14. 當檢測到NFC標籤時,意圖如何調度
- 15. didEnterRegion當應用程序未運行時
- 16. 信號檢測當信號不存在時噪聲的方差
- 17. Android信標庫 - BLE信標檢測不起作用
- 18. 自動啓動應用程序燈塔每次當檢測到信標信號
- 19. CLLocationManager不會調用didEnterRegion,雖然註冊跟蹤區域
- 20. 當用戶的光標停止使用JQuery時檢測到
- 21. QGraphicsItemText不會檢測鼠標標誌
- 22. 某些Estimote信標未被檢測到
- 23. 當用戶點擊NSTableView時檢測到
- 24. 當用戶截圖時檢測到
- 25. 當鼠標在滾動時離開trackingArea時不會調用mouseExited
- 26. 試圖獲取當前位置,但LocationManager委託永遠不會被調用
- 27. 可以[LocationManager didEnterRegion]獲取燈塔的主要和次要?
- 28. 當頁面轉到頁面時,Javascript會檢測到
- 29. 當檢測到增加時,Simulink將信號設置爲零
- 30. 當失敗時測試不會調用done()
經過問題掙扎1.5天后。問題出在飛機模式。如果啓用了飛行模式,則iBeacon的測距功能完好,但不能監測。遺憾的是沒有任何錯誤或任何 – bpolat