Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ionic3 应用程序在iOS 12.2 上因cordova-plugin-background-mode引起的闪退 #3

Open
HZYou opened this issue Mar 28, 2019 · 0 comments

Comments

@HZYou
Copy link
Owner

HZYou commented Mar 28, 2019

1.问题描述

iOS 用户把手机升级到iOS 12.2 后,app闪退。

build 到模拟器报错:

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

2.原因

经过搜索发现是cordova-plugin-background-mode插件的原因。

具体原因可参考链接:插件github地址

3. 解决办法:

/platforms/ios/myAPP/Plugins/cordova-plugin-background-mode/APPBackgroundMode.m 中,修改👇

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

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

成:

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

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

实际上就是将:_alwaysRunsAtForegroundPriority
改成了
alwaysRunsAtForegroundPriority

4. 存在的问题

修改后不一定保证cordova-plugin-background-mode 可以正常。将持续关注 此问题的解决方法。

@HZYou HZYou changed the title ionic3 应用程序在iOS 12.2 上闪退 ionic3 应用程序在iOS 12.2 上因cordova-plugin-background-mode引起的闪退 Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant