0
当在后台状态中接收到信标信号时,是否可以触发Web服务并根据响应进行操作?当iOS应用程序处于后台状态时触发WebService
我可以在背景范围内发送信标,但在发送本地通知之前,我应该检查网络服务是否通知。任何人都可以提出任何可能的方式来做到这一点这是它现在的外观。
-(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服务并获得结果。 – Paulw11 2014-09-19 10:36:43