【问题标题】:{"msg":"Fence: onClientEventRegionState, invalid state", "regionState":"0"} in ios{"msg":"Fence: onClientEventRegionState, 无效状态", "regionState":"0"} 在 ios
【发布时间】:2016-10-08 05:22:17
【问题描述】:

我想在用户到达特定楼层时使用 estimote 信标通知用户。为了完成我的任务,我开发了如下代码:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.

    self.beaconManager.delegate = self

    self.beaconManager.requestAlwaysAuthorization()
    let firstFloorRegion = CLBeaconRegion(
        proximityUUID: uuid,
        major: 2, identifier: "")
    firstFloorRegion.notifyOnEntry = true
    firstFloorRegion.notifyOnExit = true
    firstFloorRegion.notifyEntryStateOnDisplay = true
    self.beaconManager.startMonitoring(for: firstFloorRegion)
    self.beaconManager.requestState(for: firstFloorRegion)

    return true
}
func beaconManager(manager: AnyObject, didDetermineState region: CLBeaconRegion) {

    NSLog("didDetermineState Called")
}
private func beaconManager(manager: AnyObject, didEnterRegion region: CLBeaconRegion) {

    NSLog("DidEnterRegion Called")
}
private func beaconManager(manager: AnyObject, didExitRegion region: CLBeaconRegion) {

    NSLog("didExitRegion Called")
}

有几天它工作得很好。但从过去 2 天开始,它在 xcode 控制台中显示错误,如下所示:

[Client] {"msg":"Fence: onClientEventRegionState, invalid state", "regionState":"0"}.

我不明白这是什么意思。我也没有在互联网上找到任何解决方案。帮助我摆脱它。

【问题讨论】:

    标签: ios swift ios10


    【解决方案1】:

    我注意到 iBeacon 监控(以及一般的区域监控)在手机重启后最多需要 10 分钟才能工作。果然,我重新启动了我的手机,当我打电话时,我在控制台输出中得到了你的错误

    manager.requestState(for: myRegion)
    

    我从未见过苹果谈论打电话的任何负面影响

    manager.startMonitoring(for: myRegion)
    

    在已注册的区域上。但是,我不会在每次应用启动时都调用它。相反,我会像这样检查受监控的区域:

    for monitoredRegion in self.locationManager.monitoredRegions as! Set<CLBeaconRegion> {
    
       print("Monitoring: " + monitoredRegion.proximityUUID.uuidString + " " + monitoredRegion.identifier)
    
       self.locationManager.requestState(for: monitoredRegion)
    
       switch monitoredRegion.proximityUUID.uuidString {
          case myRegionUUID.uuidString:
             needToMonitorMyRegion = false
          default:
             break
        }
    }
    

    当我像这样验证注册时,我没有收到错误消息。我只在手机重启时出现错误。

    【讨论】:

      猜你喜欢
      • 2015-06-10
      • 1970-01-01
      • 1970-01-01
      • 2016-10-29
      • 2017-09-02
      • 1970-01-01
      • 2015-10-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多