繁体   English   中英

IOS 错误:由于ionic3 中未捕获的异常“NSUnknownKeyException”而终止应用程序?

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

在 iOS 9.0 上,我的应用程序在启动后立即终止,在 xcode 中显示此消息

*** 由于未捕获的异常“NSUnknownKeyException”而终止应用程序,原因:“[setValue:forUndefinedKey:]:此类不符合键视图的键值编码。”

我尝试了所有方法来解决上述错误,但没有任何效果。我正在使用后台模式插件来获取后台模式中的位置。我尝试了以下解决方案:

尝试过的解决方案

第一个解决方案:

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

删除行 APPBackgroundMode.m:266 & 267: [obj setValue:[NSNumber numberWithBool:YES] <--- 删除! forKey:[APPBackgroundMode wkProperty]]; <---移除!

第二种解决方案:

尝试在文件 src\\ios\\APPBackgroundMode.m 中替换以下几行

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

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

下面我们已经提到了 config.xml 文件

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

我尝试了所有解决方案,但没有任何效果,请团队帮助我如何解决?

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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