gpt4 book ai didi

ios - iBeacons : If app is in background, locationManager: didEnterRegion: 仅在显示锁屏时调用

转载 作者:技术小花猫 更新时间:2023-10-29 11:05:00 26 4
gpt4 key购买 nike

我正在开发一个监视 iBeacon 区域的 iOS 应用程序。当应用程序在后台运行时,我希望它在遇到特定 iBeacon 区域时发送本地通知。一切正常,除了一件事:locationManager: didEnterRegion 显然在用户显示锁定屏幕之前不会被调用。因此,即使设备在应用程序处于后台时通过 iBeacon 区域,它们也不会收到通知,直到它们显示锁定屏幕。

我也尝试过使用 startMonitoringForRegion,这种方法很有效——如果应用程序在后台运行,locationManager: didDetermineState: 在设备进入 iBeacon 区域时触发。然而,它只会执行一次——如果用户随后退出并重新进入 iBeacon 区域,locationManager: didDetermineState 不会再次触发。

我正在运行 iPhone 5s 并使用 iPhone 4s 作为 iBeacon,如果这有什么不同的话。

更正: 这种现象显然只有在我使用iPhone 4s作为客户端时才会出现。如果我使用 5s,通知会立即发送。

最佳答案

只是想获取更多信息。您是否在 CLBeaconRegion 上将 notifyEntryStateOnDisplay 设置为 YES?听起来像。

来自文档:

When set to YES, the location manager sends beacon notifications when the user turns on the display and the device is already inside the region. These notifications are sent even if your app is not running. In that situation, the system launches your app into the background so that it can handle the notifications. In both situations, the location manager calls the locationManager:didDetermineState:forRegion: method of its delegate object.

The default value for this property is NO.

关于ios - iBeacons : If app is in background, locationManager: didEnterRegion: 仅在显示锁屏时调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19434637/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com