NSInternalInconsistencyException:'无效参数不满足:!stayUp || CLClientIsBackgroundable(内部 - > fClient)"

Dan*_*elG 28 objective-c ios ios9 xcode7

我正在尝试让我的应用程序在Xcode 7测试版中工作,但我遇到了这个例外:

NSInternalInconsistencyException: 'Invalid parameter not satisfying: !stayUp || CLClientIsBackgroundable(internal->fClient)'
Run Code Online (Sandbox Code Playgroud)

这是callstack:

0   CoreFoundation                      0x00000001063a89b5 __exceptionPreprocess + 165
1   libobjc.A.dylib                     0x0000000105e20deb objc_exception_throw + 48
2   CoreFoundation                      0x00000001063a881a +[NSException raise:format:arguments:] + 106
3   Foundation                          0x00000001036f8b72 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
4   CoreLocation                        0x00000001031c7fe3 CLClientGetCapabilities + 8270
5   peach                               0x00000001020c0ee9 -[PeachesBatteryOptimizer initWithDelegate:] + 761
6   peach                               0x0000000102086d25 -[PeachAgent init] + 1141
7   peach                               0x000000010208682c __23+[PeachAgent instance]_block_invoke + 76
8   libdispatch.dylib                   0x00000001068604bb _dispatch_client_callout + 8
9   libdispatch.dylib                   0x000000010684bedc dispatch_once_f + 543
10  peach                               0x00000001020867bb +[PeachAgent instance] + 139
11  peach                               0x0000000102086f4d +[PeachAgent createInstanceWithAppKey:andInternal:useDevApi:] + 93
12  peach                               0x0000000101e2b710 -[ABCAppDelegate createPeachAgent] + 368
13  peach                               0x0000000101e28703 -[ABCAppDelegate application:didFinishLaunchingWithOptions:] + 243
...
Run Code Online (Sandbox Code Playgroud)

有没有人在iOS 9 beta 5上看过这个?

igr*_*ech 60

我设法通过做这两件事来解决这个问题:

  • UIBackgroundModes"位置" 添加到Info.plist
  • 添加NSLocationAlwaysUsageDescription到Info.plist

从iOS 11开始,密钥命名为:

  • NSLocationAlwaysAndWhenInUseUsageDescriptionNSLocationWhenInUseUsageDescription

  • 这是一个你回到自己的帖子找出来,如何解决它的情况.:O) (16认同)
  • http://stackoverflow.com/questions/30808192/allowsbackgroundlocationupdates-in-cllocationmanager-in-ios9 (2认同)
  • 用Swift 4为我工作. (2认同)

Vis*_*ela 12

只需选择您的应用方案,然后根据我的图片转到功能,一切都应该正常工作.

在此输入图像描述

  • 这解决了我的问题。谢谢。 (2认同)

Met*_*ete 9

如果像我一样想要[CLLocationManager setAllowsBackgroundLocationUpdates:]在单独的项目模块/静态库中使用,这是另一种解决方案.如果使用该模块/库的应用程序没有位置后台功能,您将会崩溃...我使用以下方法使呼叫安全:

- (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];
        }
    }
}
Run Code Online (Sandbox Code Playgroud)


Jay*_*bey 8

我有类似的问题。以下是修复此崩溃问题的步骤(使用 Xcode 11.3)。

  1. 添加Privacy - Location usage descriptionInfo.plist您的项目。

第1步

  1. 加入Background ModesCapability你的项目目标。

第2步

  1. 选择Location Update选项

第 3 步


小智 5

我在混合应用程序上遇到了同样的问题。

我已启用后台模式。

Apple 拒绝了我的应用程序。据说没有后台模式的功能。

所以我对“BackgroundGeolocationDelegate.m”进行了以下更改

  1. locationManager.allowsBackgroundLocationUpdates = NO;

  2. 然后:

    if (authStatus == kCLAuthorizationStatusNotDetermined) {
        if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {  //iOS 8.0+
            NSLog(@"BackgroundGeolocationDelegate requestAlwaysAuthorization");
            [locationManager requestWhenInUseAuthorization];
        }
    }
    
    Run Code Online (Sandbox Code Playgroud)

没有再发生车祸。

注意:修复仅适用于混合应用程序