Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic app crashes on iOS 12.2 because of '_alwaysRunsAtForegroundPriority'

On iOS 12.2 my app is terminated just after startup, 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 _alwaysRunsAtForegroundPriority.'

Anyone who can point me in the right direction for this one? I see that there has been some warnings about this earlier:

How to resolve app validation "The app references non-public selectors in Payload/MyApp.app/MyApp: _setAlwaysRunsAtForegroundPriority:"?

The answer to that post is that it's a security warning from webview that can be ignored. But when it's crashing my app, it can't really be ignored anymore :)

Thanks in advance for any help.

Lars

Update Feb 2nd 2019: It looks like it's the cordova-plugin-background-mode that causes the error. But i must admit that i have no idea how to fix that. It works when i remove that plugin from my project. But i need that plugin, or at least the background-mode functionality, so i need to fix this, somehow.

Update Feb 5th 2019: @coderroggie: I also have the version 2.3.2 of the cordova-plugin-ionic-webview plugin. It's strange that it works for me only when removing the cordova-plugin-background-mode (version 0.7.2)

I'll post my ionic info, if that can provide you with any helpful information.

Ionic:

ionic (Ionic CLI) : 4.9.0 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2 @ionic/app-scripts : 3.2.1

Cordova:

cordova (Cordova CLI) : 8.1.2 ([email protected]) Cordova Platforms : ios 4.5.5 Cordova Plugins : cordova-plugin-ionic 5.2.9, cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.3.2, (and 22 other plugins)

System:

ios-deploy : 1.9.2 NodeJS : v8.11.1 (/usr/local/bin/node)
npm : 6.4.1 OS : macOS Mojave Xcode : Xcode 10.1 Build version 10B61

Update Feb 2nd (again)

My plugins:

cordova-android-firebase-gradle-release 1.0.2 "cordova-android-firebase-gradle-release"
cordova-android-play-services-gradle-release 1.4.3 "cordova-android-play-services-gradle-release"
cordova-android-support-gradle-release 1.4.4 "cordova-android-support-gradle-release"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-background-mode 0.7.2 "BackgroundMode"
cordova-plugin-badge 0.8.7 "Badge"
cordova-plugin-camera 4.0.3 "Camera"
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-customurlscheme 4.3.0 "Custom URL scheme"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-file-transfer 1.7.1 "File Transfer"
cordova-plugin-geolocation 4.0.1 "Geolocation"
cordova-plugin-ionic 5.2.9 "cordova-plugin-ionic"
cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 2.3.2 "cordova-plugin-ionic-webview"
cordova-plugin-local-notification 0.9.0-beta.2 "LocalNotification"
cordova-plugin-mauron85-background-geolocation 3.0.0-alpha.49 "CDVBackgroundGeolocation"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-safariviewcontroller 1.5.4 "SafariViewController"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-vibration 3.1.0 "Vibration"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-support-google-services 1.1.0 "cordova-support-google-services"
cordova.plugins.diagnostic 4.0.7 "Diagnostic"
ionic-plugin-keyboard 2.2.1 "Keyboard"
phonegap-plugin-push 2.1.3 "PushPlugin"

like image 355
larschla Avatar asked Feb 01 '19 07:02

larschla


2 Answers

In the plugin there's a 'setValue' towards the bottom that nukes the app. Got a build going for 12.2. Try

ionic cordova plugin add https://github.com/iowayankee/cordova-plugin-background-mode.git

package.json

    "cordova-plugin-background-mode": "git+https://github.com/iowayankee/cordova-plugin-background-mode.git",

config.xml

    <plugin name="cordova-plugin-background-mode" spec="git+https://github.com/iowayankee/cordova-plugin-background-mode.git" />

Hopefully helps someone at least get the build going

like image 196
iowayankee Avatar answered Sep 19 '22 13:09

iowayankee


Try this. Download plugin cordova-plugin-background-mode or cordova-plugin-better-background-mode in your local folder, attach it to project as a local plugin. Go to plugin file src\ios\APPBackgroundMode.m and replace following lines

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

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

with

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

    return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}
like image 25
Sergey Mohov Avatar answered Sep 20 '22 13:09

Sergey Mohov