简体   繁体   中英

IOS error : Terminating app due to uncaught exception 'NSUnknownKeyException' in ionic3?

On iOS 9.0 my app is terminated just after launch, with this message in xcode

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.'

I tried each and everything for solve above error but nothing worked for.i am using background mode plugin for for get location in background mode.i tried below soltion's:

Tried Solution

1st solution:

https://github.com/katzer/cordova-plugin-background-mode/issues/419

Removing lines APPBackgroundMode.m:266 & 267: [obj setValue:[NSNumber numberWithBool:YES] <--- remove! forKey:[APPBackgroundMode wkProperty]]; <--- remove!

2nd solution:

Try in file src\\ios\\APPBackgroundMode.m replace following lines

+ (NSString*) wkProperty {
    NSString* str = @"YWx3YXlzUnVuc0F0Rm9yZWdyb3VuZFByaW9yaXR5";
    NSData* data  = [[NSData alloc] initWithBase64EncodedString:str options:0];

    return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; }

Below we have mentioned the config.xml file

    <edit-config file="*-Info.plist" mode="merge" target="NSLocationWhenInUseUsageDescription">
    <string>This App wants to track your location</string>
</edit-config>
<plugin name="cordova-sqlite-storage" spec="^2.6.0" />
<plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.1" />
<plugin name="cordova-plugin-advanced-http" spec="^2.0.2" />
<plugin name="cordova-plugin-statusbar" spec="2.4.2" />
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
<plugin name="cordova-plugin-filepath" spec="~1.5.1" />
<plugin name="cordova-plugin-actionsheet" spec="~2.3.3" />
<plugin name="cordova-plugin-document-viewer" spec="~0.9.10" />
<plugin name="cordova-plugin-inappbrowser" spec="~3.0.0" />
<plugin name="cordova-plugin-camera" spec="~4.0.3" />
<plugin name="cordova-plugin-file" spec="~6.0.1" />
<plugin name="cordova-plugin-datepicker" spec="~0.9.3" />
<plugin name="cordova-plugin-file-transfer" spec="~1.7.1" />
<plugin name="cordova-plugin-network-information" spec="~2.0.1" />
<plugin name="cordova-plugin-telerik-imagepicker" spec="~2.2.2">
    <variable name="PHOTO_LIBRARY_USAGE_DESCRIPTION" value="your usage message" />
</plugin>
<plugin name="cordova-plugin-uniquedeviceid" spec="^1.3.2" />
<plugin name="cordova.plugins.diagnostic" spec="4.0.11" />
<plugin name="org.apache.cordova.geolocation" spec="^0.3.6" />
<plugin name="cordova-plugin-android-permissions" spec="^1.0.0" />
<plugin name="cordova-plugin-request-location-accuracy" spec="2.3.0">
    <variable name="PLAY_SERVICES_LOCATION_VERSION" value="16.+" />
</plugin>
<plugin name="cordova-plugin-nativegeocoder" spec="3.2.2" />
<plugin name="cordova-plugin-fcm-with-dependecy-updated" spec="2.4.0" />
<plugin name="cordova-plugin-background-mode" spec="0.7.2" />
<plugin name="cordova-plugin-mauron85-background-geolocation" spec="2.3.6">
    <variable name="GOOGLE_PLAY_SERVICES_VERSION" value="11+" />
    <variable name="ANDROID_SUPPORT_LIBRARY_VERSION" value="23+" />
    <variable name="ICON" value="@mipmap/icon" />
    <variable name="SMALL_ICON" value="@mipmap/icon" />
    <variable name="ACCOUNT_NAME" value="@string/app_name" />
    <variable name="ACCOUNT_LABEL" value="@string/app_name" />
    <variable name="ACCOUNT_TYPE" value="$PACKAGE_NAME.account" />
    <variable name="CONTENT_AUTHORITY" value="$PACKAGE_NAME" />
    <variable name="ALWAYS_USAGE_DESCRIPTION" value="This app always requires location tracking" />
</plugin>
<plugin name="cordova-plugin-local-notification" spec="0.9.0-beta.2" />
<plugin name="cordova-plugin-ionic-webview" spec="4.1.1">
    <variable name="ANDROID_SUPPORT_ANNOTATIONS_VERSION" value="27.+" />
</plugin>

i tried all solution but nothing worked for me please team help me how to fix?

最后我在禁用 WKWebView 并在 config.xml 中使用 UIWebView 后修复了上述问题(仅在 ionic 3 而非 ionic4 中测试)

 <preference name="CordovaWebViewEngine" value="CDVUIWebViewEngine" >

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM