ios - 云台背景检测
<p><p>当应用处于后台时,是否有合理的方法来检测云台信标?<br/>
我目前的解决方案是在应用启动时启动 Gimbal 服务并启动访问管理器。这样我每次进入信标区域时都会收到事件(即使在后台)。<br/>
我相信必须有一个更优雅的解决方案,因为我不能让服务始终启动,搜索访问。另外,我观察到经理会在某个时候停止发送回调。 </p>
<p>如果我总是想知道信标访问(包括背景),你认为什么时候启动/停止服务和启动/停止访问管理器更好?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>Gimbal VisitManager 回调在后台调用,但它们似乎有点不可靠。 (可能只是我的测试。)</p>
<p>在我的测试中(将 Gimbal Series 10 设置为默认设置),当我取出电池时,我没有收到“didDepart”回调,但是当我将电池放回原位时,我同时得到了两个。将信标走到 20 米外并没有再次触发它们,可能是我等待的时间不够长,等等。</p>
<pre><code>// Definitely can trigger from background
- (void)didArrive:(FYXVisit *)visit;
- (void)didDepart:(FYXVisit *)visit;
// Handy code to discover when the background method is called
- (void)didArrive:(FYXVisit *)visit {
UILocalNotification* localNotification = [ init];
localNotification.fireDate = ;
localNotification.alertBody = @"Gimbal Arrive Visit";
localNotification.timeZone = ;
[ scheduleLocalNotification:localNotification];
}
</code></pre>
<hr/>
<p>您也可以将它们置于 iBeacon 模式 <a href="https://stackoverflow.com/a/22666967" rel="noreferrer noopener nofollow">https://stackoverflow.com/a/22666967</a>然后使用标准回调。这对我来说 100% 的时间都有效,在我到达为 iBeacon 模式配置的信标附近后不久调用 didEnterRegion。</p>
<pre><code>self.locationManager = [ init];
self.locationManager.delegate = self;
// Start monitoring the region (called on app start, etc.)
NSUUID *frontDoorID = [ initWithUUIDString:@"FC3DAF5A-6223-4D71-9DCD-452DC95E6CDF"];
CLBeaconMajorValue major = 1000;
CLBeaconMinorValue minor = 2000;
CLBeaconRegion *beaconRegion = [ initWithProximityUUID:frontDoorID
major:major
minor:minor
identifier:@"entrance"];
;
// Called even in the background
-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
NSLog(@"Arrived at Beacon");
// Fire a local notification to show an indication that the background event happened
UILocalNotification* localNotification = [ init];
localNotification.fireDate = ;
localNotification.alertBody = @"Beacon Found";
localNotification.timeZone = ;
[ scheduleLocalNotification:localNotification];
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 云台背景检测,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/21401021/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/21401021/
</a>
</p>
页:
[1]