【发布时间】:2016-08-24 08:45:28
【问题描述】:
我已经为我的 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 如何在内部使用这些功能以及如何使应用程序在使用它时检测到已经在范围内的信标?
【问题讨论】:
标签: ios google-nearby