首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >StandBy中的iOS -区域监控

StandBy中的iOS -区域监控
EN

Stack Overflow用户
提问于 2017-12-07 14:23:46
回答 0查看 63关注 0票数 0

我已经实现了一个信标监控功能(didEnterRegion)。如果我使用我的iPhone,它会工作得很好。(应用程序在前台、后台或仅安装并关闭,但我的iPhone必须在使用中(屏幕打开)。)

如果我的电话处于standBy模式(按下顶部按钮),我不会收到didEnterRegion的通知。如果我使用我的电话(屏幕打开),则会弹出通知。是否有机会让didEnterRegion事件也处于待机模式?

代码语言:javascript
复制
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上测试

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47688856

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档