katzer / cordova-plugin-background-mode

Keep app running in background
Apache License 2.0
1.38k stars 1.02k forks source link

crash: wkwebview and this plugin not happy #307

Open dylanvdmerwe opened 7 years ago

dylanvdmerwe commented 7 years ago

I am using version 0.7.2 with ionic's wkwebview plugin.

On start the apps crash with the following information:

2017-08-09 12:32:05.461888+0200 Cochrane+[734:238485] Apache Cordova native platform version 4.4.0 is starting.
2017-08-09 12:32:05.461976+0200 Cochrane+[734:238485] Multi-tasking -> Device: YES, App: YES
[INFO] GCDWebServer started on port 8080 and reachable at http://localhost:8080/
2017-08-09 12:32:05.478130+0200 Cochrane+[734:238485] CDVWKWebViewEngine: trying to inject XHR polyfill
2017-08-09 12:32:05.492017+0200 Cochrane+[734:238485] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<WKWebViewConfiguration 0x1701bcd20> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key _requiresUserActionForMediaPlayback.'
*** First throw call stack:
(0x18665afe0 0x1850bc538 0x18665aca8 0x18707068c 0x100171d80 0x1001729ec 0x1001c7cd4 0x1001c741c 0x1001c78b0 0x1001c4ff0 0x100049034 0x18c78cb04 0x18c78c6e0 0x18c792f60 0x18c7903fc 0x18c801e68 0x1001c999c 0x100048d50 0x10015f230 0x18c7fde48 0x18ca0a37c 0x18ca0fe24 0x18ca248b0 0x18ca0d0b8 0x188204884 0x1882046f0 0x188204aa0 0x18660942c 0x186608d9c 0x1866069a8 0x186536da4 0x18c7f6fc8 0x18c7f1c9c 0x100048c40 0x18554559c)
libc++abi.dylib: terminating with uncaught exception of type NSException

image

I've logged this as well over here and a comment was to:

I have modified a fork of it for myself but basically you just need to comment the lines as below in the background-mode plugin and it will work fine:

/**
*forKey:@"_requiresUserActionForMediaPlayback"]; * causes crash on ios10 with wk
*
* [obj setValue:[NSNumber numberWithBool:NO]
*        forKey:@"_requiresUserActionForMediaPlayback"];
*/

Any ideas on how to properly fix this going forward?

Some further environment info:

cli packages: (/Users/dylan/Desktop/Projects/CochranePlus/node_modules)

    @ionic/cli-plugin-cordova       : 1.6.2
    @ionic/cli-plugin-ionic-angular : 1.4.1
    @ionic/cli-utils                : 1.7.0
    ionic (Ionic CLI)               : 3.7.0

global packages:

    Cordova CLI : 7.0.1

local packages:

    @ionic/app-scripts : 2.1.3
    Cordova Platforms  : ios 4.4.0
    Ionic Framework    : ionic-angular 3.6.0

System:

    Node       : v6.10.3
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.3 Build version 8E3004b
    ios-deploy : 1.9.1
    ios-sim    : 6.0.0
    npm        : 5.3.0
5uper commented 7 years ago

i have fix it here, try it bugfix for WKWebViewEngine app crash

dylanvdmerwe commented 7 years ago

This issue has been open for a while now. Is there any chance of the main plugin being fixed so that wkwebview will work?

osterland commented 6 years ago

actually i think this isnt a working fix, just a workaround to get rid of the initial error :/

dylanvdmerwe commented 6 years ago

Note this is still an issue in 0.7.2.

scriptcodeDE commented 6 years ago

This is still an issue... This issue is over one year old and has not beeing merged this fix: https://github.com/5uper/cordova-plugin-background-mode/commit/bf7d2dde66daea06d7b1bef3af08e8095f660739

JeanRoldanDev commented 5 years ago

Esta fue la solución image

daviddickson commented 5 years ago

This issue appears fixed on version 0.7.2 of this repo, but running Ionic V3 CLI commands (https://ionicframework.com/docs/v3/native/background-mode/) to install the Ionic Native package and this repo loads this without the bug fix. I also noticed that the code in the npm registry (https://registry.npmjs.org/cordova-plugin-background-mode/-/cordova-plugin-background-mode-0.7.2.tgz) doesn't contain the fix.

yucomds commented 5 years ago

This issue appears fixed on version 0.7.2 of this repo, but running Ionic V3 CLI commands (https://ionicframework.com/docs/v3/native/background-mode/) to install the Ionic Native package and this repo loads this without the bug fix. I also noticed that the code in the npm registry (https://registry.npmjs.org/cordova-plugin-background-mode/-/cordova-plugin-background-mode-0.7.2.tgz) doesn't contain the fix.

I confirm this. Can you fix?

hatimox commented 5 years ago

i have the same issue , any fix ? thanks

daviddickson commented 5 years ago

See https://github.com/katzer/cordova-plugin-background-mode/issues/431. There seems to be confusion with how the functionality of this plugin is supposed to work.

MInesGomes commented 5 years ago

I installed

https://github.com/lkonzen-garupa/cordova-plugin-background-mode

and add the code for wake_lock

Is working for android 5, 7 and 10 :-)

dhayaljaswantgit commented 5 years ago

use following commands to fix that issue :

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

kapilSoni101 commented 5 years ago

@5uper : sir its not worked for me pelase tell me any another solution?