Ionic app crashes on iOS 12.2 because of '_alwaysRunsAtForegroundPriority'

喜欢而已 提交于 2019-12-03 03:20:00

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

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];
}

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.

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.

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!