diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dfe513..3e6052b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ ## ChangeLog +#### Version 0.7.2 (02.02.2017) +- Fixed app freeze on iOS using wkwebview-engine +- Websocket sample in SampleApp + #### Version 0.7.1 (30.01.2017) - Bug fixes for iOS9 and Android - Allow app to be excluded from recent list on Android diff --git a/README.md b/README.md index edca73d..1ddcb60 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,6 @@ Or install from local source: $ cordova plugin add cordova-plugin-background-mode --searchpath -__Note:__ In combination with the `cordova-plugin-wkwebview-engine` plugin the UIBackgroundModes section added by the plugin inside the *-Info.plist can be removed. That might increase the chance to submit the app to the app store. - ## Usage The plugin creates the object `cordova.plugins.backgroundMode` and is accessible after the *deviceready* event has been fired. @@ -71,8 +69,6 @@ cordova.plugins.backgroundMode.disable(); cordova.plugins.backgroundMode.setEnabled(false); ``` -__Note:__ By using `wkwebview-engine` on iOS, the plugin is enabled by default and cannot be disabled. - ### Check if running in background Once the plugin has been enabled and the app has entered the background, the background mode becomes active. diff --git a/src/ios/APPBackgroundMode.m b/src/ios/APPBackgroundMode.m index d11dbd7..14ca0ea 100644 --- a/src/ios/APPBackgroundMode.m +++ b/src/ios/APPBackgroundMode.m @@ -50,7 +50,7 @@ NSString* const kAPPBackgroundEventDeactivate = @"deactivate"; */ - (void) pluginInitialize { - enabled = [self.class isRunningWebKit]; + enabled = NO; [self configureAudioPlayer]; [self configureAudioSession]; [self observeLifeCycle]; @@ -74,9 +74,6 @@ NSString* const kAPPBackgroundEventDeactivate = @"deactivate"; name:UIApplicationWillEnterForegroundNotification object:nil]; - if ([self.class isRunningWebKit]) - return; - [listener addObserver:self selector:@selector(handleAudioSessionInterruption:) name:AVAudioSessionInterruptionNotification @@ -105,7 +102,7 @@ NSString* const kAPPBackgroundEventDeactivate = @"deactivate"; */ - (void) disable:(CDVInvokedUrlCommand*)command { - if (!enabled || [self.class isRunningWebKit]) + if (!enabled) return; enabled = NO; @@ -124,10 +121,7 @@ NSString* const kAPPBackgroundEventDeactivate = @"deactivate"; if (!enabled) return; - if (![self.class isRunningWebKit]) { - [audioPlayer play]; - } - + [audioPlayer play]; [self fireEvent:kAPPBackgroundEventActivate]; } @@ -140,7 +134,7 @@ NSString* const kAPPBackgroundEventDeactivate = @"deactivate"; NSLog(@"BackgroundMode: On simulator apps never pause in background!"); } - if (audioPlayer.isPlaying || [self.class isRunningWebKit]) { + if (audioPlayer.isPlaying) { [self fireEvent:kAPPBackgroundEventDeactivate]; } @@ -173,9 +167,6 @@ NSString* const kAPPBackgroundEventDeactivate = @"deactivate"; AVAudioSession* session = [AVAudioSession sharedInstance]; - if ([self.class isRunningWebKit]) - return; - // Don't activate the audio session yet [session setActive:NO error:NULL]; @@ -275,6 +266,9 @@ NSString* const kAPPBackgroundEventDeactivate = @"deactivate"; [obj setValue:[NSNumber numberWithBool:YES] forKey:[APPBackgroundMode wkProperty]]; + [obj setValue:[NSNumber numberWithBool:NO] + forKey:@"_requiresUserActionForMediaPlayback"]; + return obj; } SwizzleSelectorWithBlock_End; diff --git a/www/background-mode.js b/www/background-mode.js index cd67b14..7dcdff3 100644 --- a/www/background-mode.js +++ b/www/background-mode.js @@ -341,8 +341,9 @@ exports.pluginInitialize = function () { this._isAndroid = device.platform.match(/^android|amazon/i) !== null; this.setDefaults({}); - if (device.platform == 'browser' || window.webkit !== undefined) { + if (device.platform == 'browser') { this.enable(); + this._isEnabled = true; } this._isActive = this._isActive || device.platform == 'browser';