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