I\'m trying to get my app working in Xcode 7 beta but I\'m hitting this exception:
NSInternalInconsistencyException: \'Invalid parameter not satisfying: !sta
I had similar issue. Below are steps to fix this crash issue (using Xcode 11.3).
Privacy - Location usage description
in Info.plist
of your project.Background Modes
as Capability
in your Project Target.Location Update
optionI faced same issue on Hybrid app.
I have enabled background mode ON.
Apple has rejected my app. Saying there is no features for background mode.
So I made following changes on "BackgroundGeolocationDelegate.m"
1.locationManager.allowsBackgroundLocationUpdates = NO;
if (authStatus == kCLAuthorizationStatusNotDetermined) {
if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { //iOS 8.0+
NSLog(@"BackgroundGeolocationDelegate requestAlwaysAuthorization");
[locationManager requestWhenInUseAuthorization];
}
}
There was no more crash. Note *: Fix is only for hybrid app
Just select your app scheme and go to Capabilities as per my picture below everything should work fine.
We need to add UIBackground Mode capabilities.
In my case CLLocation manager is working in background mode and I checked Location Updates
key which is added into Info.plist.
Here's another solution if like me you want to use [CLLocationManager setAllowsBackgroundLocationUpdates:]
in a separate project module / static library. You'll get this crash if the app using that module/library doesn't have the location background capability... I made the following method to make the call safe:
- (void) setAllowsBackgroundLocationUpdatesSafely
{
NSArray* backgroundModes = [[NSBundle mainBundle].infoDictionary objectForKey:@"UIBackgroundModes"];
if(backgroundModes && [backgroundModes containsObject:@"location"]) {
if([mLocationManager respondsToSelector:@selector(setAllowsBackgroundLocationUpdates:)]) {
// We now have iOS9 and the right capabilities to set this:
[mLocationManager setAllowsBackgroundLocationUpdates:YES];
}
}
}
This happened to me as well. Instead of putting the background capability to on and potentially getting denied by apple since you don't need background locations take out all remnants to background locations. Odds are you copied and pasted the location function from an older app or maybe off a website, not that anyone does that. Anyway.
You need to comment or completely take out: This is probably in your locationmanager function.
//for use in background
self.locationManager.allowsBackgroundLocationUpdates = true
Also in your view did load and or view will appear, you need to comment or take this out as well
//for use in background
self.locationManager.requestAlwaysAuthorization()
If you leave these in when the function is called the app will complain the capability is not turned on.