Fix app freeze on iOS using wkwebview-engine

This commit is contained in:
Sebastián Katzer
2017-02-02 15:22:12 +01:00
parent 2801364ed8
commit b7a911a974
4 changed files with 13 additions and 18 deletions

View File

@@ -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;