Skip to content

Commit a1dcd9a

Browse files
authored
Merge pull request #27 from OutSystems/development
Development
2 parents 788afce + 1989ac4 commit a1dcd9a

File tree

8 files changed

+143
-89
lines changed

8 files changed

+143
-89
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,6 @@ fastlane/test_output
8888
# https://github.com/johnno1962/injectionforxcode
8989

9090
iOSInjectionProject/
91+
92+
# macOS
93+
.DS_Store

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [Unreleased]
8+
9+
### Features
10+
11+
- Add support for passing custom headers to `WKWebView` (only for the openInWebView option). [RMET-4287](https://outsystemsrd.atlassian.net/browse/RMET-4287).
12+
713
## 2.0.1
814

915
### Features

OSInAppBrowserLib/RouterAdapters/OSIABWebViewRouterAdapter.swift

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ public class OSIABWebViewRouterAdapter: NSObject, OSIABRouter {
77

88
/// Object that contains the value to format the visual presentation.
99
private let options: OSIABWebViewOptions
10+
/// Custom headers to be used by the WebView.
11+
private let customHeaders: [String: String]?
1012
/// Object that manages the browser's cache
1113
private let cacheManager: OSIABCacheManager
1214
/// Object that manages all the callbacks available for the WebView.
@@ -15,14 +17,17 @@ public class OSIABWebViewRouterAdapter: NSObject, OSIABRouter {
1517
/// Constructor method.
1618
/// - Parameters:
1719
/// - options: Object that contains the value to format the visual presentation.
20+
/// - customHeaders: Custom headers to be used by the WebView. `nil` is provided in case of no value.
1821
/// - cacheManager: Object that manages the browser's cache
1922
/// - callbackHandler: Object that manages all the callbacks available for the WebView.
2023
public init(
21-
_ options: OSIABWebViewOptions,
24+
options: OSIABWebViewOptions,
25+
customHeaders: [String: String]? = nil,
2226
cacheManager: OSIABCacheManager,
2327
callbackHandler: OSIABWebViewCallbackHandler
2428
) {
2529
self.options = options
30+
self.customHeaders = customHeaders
2631
self.cacheManager = cacheManager
2732
self.callbackHandler = callbackHandler
2833
}
@@ -36,12 +41,13 @@ public class OSIABWebViewRouterAdapter: NSObject, OSIABRouter {
3641

3742
let viewModel = OSIABWebViewModel(
3843
url: url,
39-
self.options.toConfigurationModel().toWebViewConfiguration(),
40-
self.options.allowOverScroll,
41-
self.options.customUserAgent,
42-
self.options.allowsBackForwardNavigationGestures,
43-
uiModel: self.options.toUIModel(),
44-
callbackHandler: self.callbackHandler
44+
customHeaders: customHeaders,
45+
webViewConfiguration: options.toConfigurationModel().toWebViewConfiguration(),
46+
scrollViewBounces: options.allowOverScroll,
47+
customUserAgent: options.customUserAgent,
48+
backForwardNavigationGestures: options.allowsBackForwardNavigationGestures,
49+
uiModel: options.toUIModel(),
50+
callbackHandler: callbackHandler
4551
)
4652

4753
let dismissCallback: () -> Void = { self.callbackHandler.onBrowserClosed(true) }
@@ -52,8 +58,8 @@ public class OSIABWebViewRouterAdapter: NSObject, OSIABRouter {
5258
} else {
5359
hostingController = OSIABWebView13Controller(rootView: .init(viewModel), dismiss: dismissCallback)
5460
}
55-
hostingController.modalPresentationStyle = self.options.modalPresentationStyle
56-
hostingController.modalTransitionStyle = self.options.modalTransitionStyle
61+
hostingController.modalPresentationStyle = options.modalPresentationStyle
62+
hostingController.modalTransitionStyle = options.modalTransitionStyle
5763
hostingController.presentationController?.delegate = self
5864

5965
completionHandler(hostingController)
@@ -66,23 +72,23 @@ private extension OSIABWebViewOptions {
6672
/// - Returns: The `OSIABWebViewConfigurationModel` equivalent value.
6773
func toConfigurationModel() -> OSIABWebViewConfigurationModel {
6874
.init(
69-
self.mediaTypesRequiringUserActionForPlayback,
70-
self.enableViewportScale,
71-
self.allowInLineMediaPlayback,
72-
self.surpressIncrementalRendering
75+
mediaTypesRequiringUserActionForPlayback,
76+
enableViewportScale,
77+
allowInLineMediaPlayback,
78+
surpressIncrementalRendering
7379
)
7480
}
7581

7682
/// Converts the current value to `OSIABWebViewUIModel` equivalent.
7783
/// - Returns: The `OSIABWebViewUIModel` equivalent value.
7884
func toUIModel() -> OSIABWebViewUIModel {
7985
.init(
80-
showURL: self.showURL,
81-
showToolbar: self.showToolbar,
82-
toolbarPosition: self.toolbarPosition,
83-
showNavigationButtons: self.showNavigationButtons,
84-
leftToRight: self.leftToRight,
85-
closeButtonText: self.closeButtonText
86+
showURL: showURL,
87+
showToolbar: showToolbar,
88+
toolbarPosition: toolbarPosition,
89+
showNavigationButtons: showNavigationButtons,
90+
leftToRight: leftToRight,
91+
closeButtonText: closeButtonText
8692
)
8793
}
8894
}

0 commit comments

Comments
 (0)