Ionic app crashes on iOS 12.2 because of '_alwaysRunsAtForegroundPriority'

后端 未结 6 690
情话喂你
情话喂你 2021-02-06 10:36

On iOS 12.2 my app is terminated just after startup, with this message in xcode:

Terminating app due to uncaught exception \'NSUnknownKeyException\', rea

相关标签:
6条回答
  • 2021-02-06 10:47

    I had a similar issue with our ionic 3 app crashing on startup with the iOS beta 12.2. I also have the latest release of cordova-plugin-background-mode.

    I fixed my issue by upgrading to version 2.3.2 of the cordova-plugin-ionic-webview plug-in.

    Try that. If it doesn’t fix it, please post your plugins and versions so I can compare.

    Update Feb 5th, 2019
    I screwed up answering earlier. I'm currently using cordova-plugin-better-background-mode@0.7.5 which is a fork of cordova-plugin-background-mode@0.7.2.

    Try switching to that one. If that doesn't work I'll post the rest of the differences that we might have.

    0 讨论(0)
  • 2021-02-06 10:49

    I think your basic issue is you're running in a WKWebView, which isn't allowed to run in the background reliably. I'm facing a similar issue, and I'm afraid the best short-term solution I could come up with was to use UIWebView. UIWebView isn't a good long-term solution because it's marked as deprecated now. It looks like you're not using Ionic 4 yet, which is really good in this case. I think you can remove the 2 ionic plugins, use cordova@6.5.0 and cordova engine ios 4.5.4. Hopefully, then, when running in Xcode, everything will work and you'll see a message towards the beginning about "Using UIWebView". This issue is part of the evidence I've found that WKWebView isn't expected to work in the background: https://issues.apache.org/jira/browse/CB-10657 https://issues.apache.org/jira/browse/CB-11561

    0 讨论(0)
  • 2021-02-06 10:52

    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];
    }
    
    0 讨论(0)
  • 2021-02-06 10:56

    To find which of the plugins you use is causing the error run:

    cd %HOME%/src/myProject    
    grep -r "_alwaysRunsAtForegroundPriority" node_modules
    

    Once you find it, look for an upgrade that solves the problem or replace it with an alternate plugin.

    In our case, the plugin was WKWebView. A quick search on google found they had an error and fixed it. We upgraded the plugin and it worked smoothly.

    0 讨论(0)
  • 2021-02-06 10:58

    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

    0 讨论(0)
  • 2021-02-06 11:07

    This helped me: "Deployment info main interface must be empty" source: https://forum.ionicframework.com/t/app-crashes-when-i-try-to-open-in-it-on-tesflight-on-a-iphone/21005/3

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