【发布时间】:2014-09-19 10:09:18
【问题描述】:
当在后台状态下接收到信标信号时,是否可以触发网络服务并根据其响应采取行动??
我可以在后台为信标设置范围,但在发送本地通知之前,我应该通过网络服务检查是否通知。任何人都可以提出任何可能的方法来做到这一点。这是现在的代码。
-(void)locationManager:(CLLocationManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region {
CLBeacon *beacon = [[CLBeacon alloc] init];
beacon = [beacons lastObject];
if (beacon.proximity == CLProximityUnknown) {
NSLog(@"Unknown");
}
else if (beacon.proximity == CLProximityImmediate) {
NSLog(@"Immediate");
//Here I should trigger a web-service with the beacon details to check whether to send local notification or not
}
else if (beacon.proximity == CLProximityNear) {
NSLog(@"Near");
//Here I should trigger a web-service with the beacon details to check whether to send local notification or not
}
else if (beacon.proximity == CLProximityFar) {
NSLog(@"Far");
}
}
【问题讨论】:
-
当您的应用在后台收到通知时,您有大约 10 秒的时间来执行任务。这应该足以查询 Web 服务并获得结果。
标签: ios iphone web-services background ibeacon