我已经为我的 Objective-C 项目设置了 Google Nearby API 来扫描信标。
该应用程序在进入信标范围时可以正常检测信标,但如果我在已经在范围内时启动应用程序,它就不起作用。我必须离开信标并返回。
我没有使用后台扫描。我使用的lib版本是:0.10.0
我的代码是:
[GNSMessageManager setDebugLoggingEnabled:YES];
_messageManager = [[GNSMessageManager alloc] initWithAPIKey:@"..."];
_beaconSubscription = [_messageManager subscriptionWithMessageFoundHandler:^(GNSMessage *message) {
NSLog(@"beacon found: %@",message);
...
} messageLostHandler:^(GNSMessage *message) {
NSLog(@"beacon lost: %@",message);
...
} paramsBlock:^(GNSSubscriptionParams *params) {
params.deviceTypesToDiscover = kGNSDeviceBLEBeacon;
params.beaconStrategy = [GNSBeaconStrategy strategyWithParamsBlock:^(GNSBeaconStrategyParams *params) {
params.includeIBeacons = YES;
}];
}];
我知道核心位置框架didEnterRegion / didExitRegion方法,这些方法仅在跨越信标区域边界时调用,我可以使用didDetermineState方法,但 NearbyAPI 如何在内部使用这些方法以及如何让应用程序检测到使用它时已经在范围内的信标?