Skip to content

Commit

Permalink
fix(webview): ios ensure configuration is correctly set in view creation
Browse files Browse the repository at this point in the history
  • Loading branch information
farfromrefug committed Aug 3, 2023
1 parent 1c6a4ce commit 8fefa5e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/webview/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export class AWebView extends WebViewExtBase {

public viewPortSize = { initialScale: 1.0 };
private limitsNavigationsToAppBoundDomains = false;
private allowsInlineMediaPlayback = false;
private mediaTypesRequiringUser = true;

public createNativeView() {
const configuration = WKWebViewConfiguration.new();
Expand All @@ -60,18 +62,18 @@ export class AWebView extends WebViewExtBase {
configuration.preferences.setValueForKey(true, 'allowFileAccessFromFileURLs');
configuration.setValueForKey(true, 'allowUniversalAccessFromFileURLs');
configuration.limitsNavigationsToAppBoundDomains = this.limitsNavigationsToAppBoundDomains;
configuration.mediaTypesRequiringUserActionForPlayback = this.mediaTypesRequiringUser ? WKAudiovisualMediaTypes.All : WKAudiovisualMediaTypes.None;
configuration.allowsInlineMediaPlayback = this.allowsInlineMediaPlayback;

if (this.supportXLocalScheme) {
this.wkCustomUrlSchemeHandler = new CustomUrlSchemeHandler();
configuration.setURLSchemeHandlerForURLScheme(this.wkCustomUrlSchemeHandler, this.interceptScheme);
}

const webview = new WKWebView({
return new WKWebView({
frame: CGRectZero,
configuration
});

return webview;
}

public initNativeView() {
Expand Down Expand Up @@ -455,12 +457,12 @@ export class AWebView extends WebViewExtBase {
nativeView.scrollView.userInteractionEnabled = !!enabled;
}
[mediaPlaybackRequiresUserActionProperty.setNative](enabled: boolean) {
// this.nativeViewProtected.configuration.mediaTypesRequiringUserActionForPlayback = enabled ? WKAudiovisualMediaTypes.All : WKAudiovisualMediaTypes.None;
this.nativeViewProtected.configuration.setValueForKey(enabled ? WKAudiovisualMediaTypes.All : WKAudiovisualMediaTypes.None, 'mediaTypesRequiringUserActionForPlayback');
this.nativeViewProtected.configuration.mediaTypesRequiringUserActionForPlayback = enabled ? WKAudiovisualMediaTypes.All : WKAudiovisualMediaTypes.None;
// this.nativeViewProtected.configuration.setValueForKey(enabled ? WKAudiovisualMediaTypes.All : WKAudiovisualMediaTypes.None, 'mediaTypesRequiringUserActionForPlayback');
}
[allowsInlineMediaPlaybackProperty.setNative](enabled: boolean) {
this.nativeViewProtected.configuration.setValueForKey(enabled, 'allowsInlineMediaPlayback');
// this.nativeViewProtected.configuration.allowsInlineMediaPlayback = enabled;
// this.nativeViewProtected.configuration.setValueForKey(enabled, 'allowsInlineMediaPlayback');
this.nativeViewProtected.configuration.allowsInlineMediaPlayback = enabled;
}

/**
Expand Down

0 comments on commit 8fefa5e

Please sign in to comment.