Skip to content

Commit 21fa500

Browse files
committed
Fix crashes when using WKWebView implementation on iOS 9.
Fixes apache#323. Fixes apache#324.
1 parent 27fe8ec commit 21fa500

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ instance, or the system browser.
147147
- __toolbar__: set to `yes` or `no` to turn the toolbar on or off for the InAppBrowser (defaults to `yes`)
148148
- __toolbarcolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default color of the toolbar. Only applicable if toolbar is not disabled.
149149
- __toolbartranslucent__: set to `yes` or `no` to make the toolbar translucent(semi-transparent) (defaults to `yes`). Only applicable if toolbar is not disabled.
150-
- __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`). Only applicable to UIWebView (`usewkwebview=no`).
151-
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`). Only applicable to UIWebView (`usewkwebview=no`).
152-
- __allowInlineMediaPlayback__: Set to `yes` or `no` to allow in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. The HTML's `video` element must also include the `webkit-playsinline` attribute (defaults to `no`) Only applicable to UIWebView (`usewkwebview=no`).
150+
- __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`). Only applicable to UIWebView (`usewkwebview=no`) and WKWebView (`usewkwebview=yes`) on iOS 10+.
151+
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`). Applicable to UIWebView (`usewkwebview=no`) and WKWebView (`usewkwebview=yes`).
152+
- __allowInlineMediaPlayback__: Set to `yes` or `no` to allow in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. The HTML's `video` element must also include the `webkit-playsinline` attribute (defaults to `no`). Applicable to UIWebView (`usewkwebview=no`) and WKWebView (`usewkwebview=yes`).
153153
- __keyboardDisplayRequiresUserAction__: Set to `yes` or `no` to open the keyboard when form elements receive focus via JavaScript's `focus()` call (defaults to `yes`). Only applicable to UIWebView (`usewkwebview=no`).
154154
- __suppressesIncrementalRendering__: Set to `yes` or `no` to wait until all new view content is received before being rendered (defaults to `no`). Only applicable to UIWebView (`usewkwebview=no`).
155155
- __presentationstyle__: Set to `pagesheet`, `formsheet` or `fullscreen` to set the [presentation style](http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/modalPresentationStyle) (defaults to `fullscreen`).

src/ios/CDVWKInAppBrowser.m

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -664,14 +664,20 @@ - (void)createViews
664664
[configuration.userContentController addScriptMessageHandler:self name:IAB_BRIDGE_NAME];
665665

666666
//WKWebView options
667-
configuration.ignoresViewportScaleLimits = _browserOptions.enableviewportscale;
668667
configuration.allowsInlineMediaPlayback = _browserOptions.allowinlinemediaplayback;
669-
if(_browserOptions.mediaplaybackrequiresuseraction == YES){
670-
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAll;
671-
}else{
672-
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
668+
if (@available(iOS 10.0, *)) {
669+
configuration.ignoresViewportScaleLimits = _browserOptions.enableviewportscale;
670+
if(_browserOptions.mediaplaybackrequiresuseraction == YES){
671+
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAll;
672+
}else{
673+
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
674+
}
675+
}else{ // iOS 9
676+
configuration.mediaPlaybackRequiresUserAction = _browserOptions.mediaplaybackrequiresuseraction;
673677
}
674678

679+
680+
675681
self.webView = [[WKWebView alloc] initWithFrame:webViewBounds configuration:configuration];
676682

677683
[self.view addSubview:self.webView];

0 commit comments

Comments
 (0)