我已经实现了一个信标监控功能(didEnterRegion)。如果我使用我的iPhone,它会工作得很好。(应用程序在前台、后台或仅安装并关闭,但我的iPhone必须在使用中(屏幕打开)。)
如果我的电话处于standBy模式(按下顶部按钮),我不会收到didEnterRegion的通知。如果我使用我的电话(屏幕打开),则会弹出通知。是否有机会让didEnterRegion事件也处于待机模式?
self->beaconLocationManager = [[CLLocationManager alloc] init];
[self->beaconLocationManager requestAlwaysAuthorization];
self->beaconLocationManager.delegate = self;
beaconLocationManager.allowsBackgroundLocationUpdates = YES;
NSString* beaconIdentName = [NSString stringWithFormat:@"Beacon%d", cnt];
NSUUID *uuid2=[[NSUUID alloc]initWithUUIDString:uuid];
clBeconRegion2=[[CLBeaconRegion alloc]initWithProximityUUID:uuid2 identifier:beaconIdentName];
clBeconRegion2.notifyOnEntry=YES;
clBeconRegion2.notifyEntryStateOnDisplay = NO;
[self->beaconLocationManager startMonitoringForRegion:clBeconRegion2];
[self->beaconLocationManager startRangingBeaconsInRegion:clBeconRegion2];
...
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
NSLog(@"ENTER REGION");
UILocalNotification *localNotification = [[UILocalNotification alloc]init];
localNotification.alertBody = @"FOUNDED";
localNotification.alertAction = [NSString stringWithFormat:@"%@ Connecting...", region.identifier];
[[UIApplication sharedApplication]presentLocalNotificationNow:localNotification];
}项目设置:推送通知开启。后台模式位置更新,后台抓取,使用蓝牙LE配件开启。
在iOS 11.1上测试
https://stackoverflow.com/questions/47688856
复制相似问题