NSInternalInconsistencyException: 'Invalid parameter not satisfying: !stayUp || CLClientIsBackgroundable(internal->fClient)'

前端 未结 9 762
终归单人心
终归单人心 2020-12-15 02:42

I\'m trying to get my app working in Xcode 7 beta but I\'m hitting this exception:

NSInternalInconsistencyException: \'Invalid parameter not satisfying: !sta         


        
相关标签:
9条回答
  • 2020-12-15 03:23

    I had similar issue. Below are steps to fix this crash issue (using Xcode 11.3).

    1. Add Privacy - Location usage description in Info.plist of your project.

    1. Add Background Modes as Capability in your Project Target.

    1. Select Location Update option

    0 讨论(0)
  • 2020-12-15 03:33

    I 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;

    1.  

      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

    0 讨论(0)
  • 2020-12-15 03:34

    Just select your app scheme and go to Capabilities as per my picture below everything should work fine.

    0 讨论(0)
  • 2020-12-15 03:35

    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.

    0 讨论(0)
  • 2020-12-15 03:37

    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];
            }
        }
    }
    
    0 讨论(0)
  • 2020-12-15 03:39

    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.

    0 讨论(0)
提交回复
热议问题