【发布时间】:2016-04-21 06:45:48
【问题描述】:
在收到“didEnterRegion”调用后,我正在尝试进行 API 调用。当应用程序在前面时,它工作得很好。但是,如果应用程序被停用或什至在后台,则永远不会拨打电话。我试图调试它,但是一旦“reportLocationEventToServerWithType”被称为调试器“死”并且永远不会进行调用。我认为这并不重要,但我正在使用 Estimote sdk 进行信标监控。 这是sn-ps的代码:
- (void)beaconManager:(id)manager didEnterRegion:(CLBeaconRegion *)region{
UIApplication *app = [UIApplication sharedApplication];
NSNumber * mallID = [self.dictBeaconsPerMall objectForKey:region.identifier];
Mall * mall = [Mall getMallWithID:mallID];
[ApplicationManager sharedInstance].locationManager.beaconRecognizedMall=mall;
[[NSNotificationCenter defaultCenter]postNotificationName:nLocationMallUpdated object:nil];
UILocalNotification * not = [[UILocalNotification alloc]init];
not.alertBody = [NSString stringWithFormat:@"DID Enter beacon region at: %@",mall.strTitle];
not.alertAction = @"alertAction";
not.soundName = UILocalNotificationDefaultSoundName;
[app presentLocalNotificationNow:not];
[[ApplicationManager sharedInstance].crashAndReportsManager reportLocationEventToServerWithType:@"beacon" andSubParam:region.identifier extraInfo:@{@"paramKey":@"key"}];
}
-(void)reportLocationEventToServerWithType: (NSString*)type andSubParam:(NSString*) strID extraInfo: (NSDictionary*)extraInfo{
NSString* udid = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
NSMutableDictionary * params = [[NSMutableDictionary alloc]init];
[params setObject:type forKey:@"type"];
[params setObject:strID forKey:@"subParam"];
[params setObject:udid forKey:@"udid"];
if(extraInfo)
[params addEntriesFromDictionary:extraInfo];
UserLogRequest * req = [[UserLogRequest alloc]initWithCallerObject:self andParams:params];
req.showHud=NO;
req.showMessage=NO;
[[ApplicationManager sharedInstance].requestManager sendRequestForRequest:req];
}
请求初始化和请求管理器“sendRequestForRequest”在数百万其他情况下工作正常,因此它们的实现无关紧要。
谢谢!
【问题讨论】:
标签: ios iphone background afnetworking-2 geofencing