Skip to content

Commit b60959a

Browse files
committed
Make webViewConfiguration overridable
1 parent be605b9 commit b60959a

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

InAppSettingsKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'InAppSettingsKit'
3-
s.version = '3.8.4'
3+
s.version = '3.8.5'
44
s.summary = 'This iPhone framework allows settings to be in-app in addition to being in the Settings app.'
55

66
s.description = <<-DESC

Sources/InAppSettingsKit/Controllers/IASKAppSettingsWebViewController.m

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,25 @@ - (id)initWithFile:(NSString*)urlString specifier:(IASKSpecifier*)specifier {
5555
return self;
5656
}
5757

58+
- (WKWebViewConfiguration*)webViewConfiguration {
59+
// Create a configuration for the webView, which sets the subset of properties that Interface Builder in Xcode (version 15.4) shows when adding a WKWebView. The Xcode titles are put in the comments:
60+
WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
61+
configuration.suppressesIncrementalRendering = NO; // Display: Incremental Rendering
62+
configuration.allowsAirPlayForMediaPlayback = YES; // Media: AirPlay
63+
configuration.allowsInlineMediaPlayback = YES; // Media: Inline Playback
64+
configuration.allowsPictureInPictureMediaPlayback = YES; // Media: Picture-in-Picture
65+
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAll; // Interaction: For Audio/Video Playback -> Disable automatic start explicitely, since the video will be presented fullscreen after page load.
66+
configuration.dataDetectorTypes = WKDataDetectorTypeAll; // Data Detectors: All
67+
if (@available(iOS 14.0, *)) {
68+
configuration.defaultWebpagePreferences.allowsContentJavaScript = YES; // JavaScript: Enabled
69+
}
70+
else {
71+
configuration.preferences.javaScriptEnabled = YES; // Deprecated since iOS 14.0
72+
}
73+
configuration.preferences.javaScriptCanOpenWindowsAutomatically = NO; // JavaScript: Can Auto-open Windows -> Disable explicitely for security reasons.
74+
return configuration;
75+
}
76+
5877
- (void)loadView {
5978
// Set up the main view
6079
self.view = [[UIView alloc] init];
@@ -147,24 +166,9 @@ - (void)loadView {
147166
- (void)viewDidLoad {
148167
[super viewDidLoad];
149168

150-
// Create a configuration for the webView, which sets the subset of properties that Interface Builder in Xcode (version 15.4) shows when adding a WKWebView. The Xcode titles are put in the comments:
151-
WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
152-
configuration.suppressesIncrementalRendering = NO; // Display: Incremental Rendering
153-
configuration.allowsAirPlayForMediaPlayback = YES; // Media: AirPlay
154-
configuration.allowsInlineMediaPlayback = YES; // Media: Inline Playback
155-
configuration.allowsPictureInPictureMediaPlayback = YES; // Media: Picture-in-Picture
156-
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAll; // Interaction: For Audio/Video Playback -> Disable automatic start explicitely, since the video will be presented fullscreen after page load.
157-
configuration.dataDetectorTypes = WKDataDetectorTypeAll; // Data Detectors: All
158-
if (@available(iOS 14.0, *)) {
159-
configuration.defaultWebpagePreferences.allowsContentJavaScript = YES; // JavaScript: Enabled
160-
}
161-
else {
162-
configuration.preferences.javaScriptEnabled = YES; // Deprecated since iOS 14.0
163-
}
164-
configuration.preferences.javaScriptCanOpenWindowsAutomatically = NO; // JavaScript: Can Auto-open Windows -> Disable explicitely for security reasons.
165169

166170
// Initialize the webView with the configuration in an empty frame (size will be updated in `-viewWillLayoutSubviews` after constraints have been added):
167-
self.webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration];
171+
self.webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:self.webViewConfiguration];
168172
self.webView.translatesAutoresizingMaskIntoConstraints = NO; // Disable autoresizing mask for layout constraints
169173
self.webView.navigationDelegate = self;
170174

Sources/InAppSettingsKit/include/IASKAppSettingsWebViewController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
2828
@property (nullable, nonatomic, strong, readonly) WKWebView *webView;
2929
@property (nonatomic, strong, readonly) NSURL *url;
3030
@property (nullable, nonatomic, strong) NSString *customTitle;
31+
@property (nonnull, nonatomic, readonly) WKWebViewConfiguration *webViewConfiguration;
3132

3233
@end
3334

0 commit comments

Comments
 (0)