ios - 背景中的测距信标
<p><p>我想在后台响起信标。背景我的意思是当手机进入锁定屏幕时。我希望该应用程序继续测距信标。我现在遇到的问题是代码永远找不到信标。我有两个正在工作的信标,但 AppDelegate 没有找到它们。当我在 ViewController 中运行相同的代码时,它会找到信标并显示它们。我该怎么做?</p>
<pre><code>@interface BDAppDelegate () <AXABeaconManagerDelegate>
@end
@implementation BDAppDelegate {
NSMutableDictionary *beaconRegions;
NSMutableDictionary *detectBeacons;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
CLBeaconRegion *beaconRegion = [ initWithProximityUUID:[ initWithUUIDString:@"MyUUID"] identifier:@"微信"];
.beaconDelegate = self;
[ requestAlwaysAuthorization];
[ startRangingBeaconsInRegion:beaconRegion];
self->beaconRegions = [ init];
self->detectBeacons = [ init];
while (detectBeacons.count < 10) {
NSLog(@"Rows in detectBeacons %lu", (unsigned long)beaconRegions.count);
}
self->beaconRegions = ;
}
- (void)didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region {
self->beaconRegions = beacons;
NSMutableArray *allBeacons = ;
for (NSArray *regionResult in )
{
;
}
NSPredicate *pre = ;
NSArray *rights = ;
NSString * str = @"accuracy";
self->detectBeacons = rights;
}
@end
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>在 iOS 上,<strong>应用程序被限制为在后台运行 5 秒</strong>。每次将应用程序置于后台或触发信标监视事件(进入区域/退出区域)时,都会重新启动此计时器。好消息是,<strong>您可以将允许在后台定位信标的时间延长至每次发生这些事件后的 3 分钟。</strong></p>
<p>我整理了一篇博文,向您展示如何操作 <a href="http://developer.radiusnetworks.com/2014/11/13/extending-background-ranging-on-ios.html" rel="noreferrer noopener nofollow">here.</a> </p></p>
<p style="font-size: 20px;">关于ios - 背景中的测距信标,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/33126936/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/33126936/
</a>
</p>
页:
[1]