使用最短600秒的计时器安排setKeepAliveTimeout
会使我的应用程序在几小时(6-7)小时内运行良好。
/////////// VOIP HANLDER - BEGIN ///////////
BOOL handlerAccepted = [[UIApplication sharedApplication] setKeepAliveTimeout:kINTERVAL_10_MINUTES handler:^{
CLLocation *currentLocation = [RegionMonitoringService sharedInstance].locationManager.location;
#ifdef DEBUG
NSString *locationDescription = [NSString stringWithFormat:@"VOIP Location: {%f, %f}, Time: %@",
currentLocation.coordinate.latitude, currentLocation.coordinate.longitude,
[currentLocation.timestamp description]];
NSLog(@"setKeepAliveTimeout, %@", locationDescription);
// GeneratePushNotification(locationDescription);
#endif
[[ServerApiManager sharedInstance] saveLocation:currentLocation];
// Register a geofence
[[RegionMonitoringService sharedInstance] startMonitoringForLocation:currentLocation];
}];
#ifdef DEBUG
NSLog(@"VOIP handler installed: %@", handlerAccepted?@"YES":@"NO");
#endif
/////////// VOIP HANLDER - END ///////////
在我测试的所有设备中都会发生这种情况。 为什么会这样?