Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,6 @@ fastlane/test_output
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/

# macOS
.DS_Store
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Features

- Add support for passing custom headers to `WKWebView` (only for the openInWebView option). [RMET-4287](https://outsystemsrd.atlassian.net/browse/RMET-4287).

## 2.0.1

### Features
Expand Down
Binary file modified OSInAppBrowserLib.zip
Binary file not shown.
44 changes: 25 additions & 19 deletions OSInAppBrowserLib/RouterAdapters/OSIABWebViewRouterAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class OSIABWebViewRouterAdapter: NSObject, OSIABRouter {

/// Object that contains the value to format the visual presentation.
private let options: OSIABWebViewOptions
/// Custom headers to be used by the WebView.
private let customHeaders: [String: String]?
/// Object that manages the browser's cache
private let cacheManager: OSIABCacheManager
/// Object that manages all the callbacks available for the WebView.
Expand All @@ -15,14 +17,17 @@ public class OSIABWebViewRouterAdapter: NSObject, OSIABRouter {
/// Constructor method.
/// - Parameters:
/// - options: Object that contains the value to format the visual presentation.
/// - customHeaders: Custom headers to be used by the WebView. `nil` is provided in case of no value.
/// - cacheManager: Object that manages the browser's cache
/// - callbackHandler: Object that manages all the callbacks available for the WebView.
public init(
_ options: OSIABWebViewOptions,
options: OSIABWebViewOptions,
customHeaders: [String: String]? = nil,
cacheManager: OSIABCacheManager,
callbackHandler: OSIABWebViewCallbackHandler
) {
self.options = options
self.customHeaders = customHeaders
self.cacheManager = cacheManager
self.callbackHandler = callbackHandler
}
Expand All @@ -36,12 +41,13 @@ public class OSIABWebViewRouterAdapter: NSObject, OSIABRouter {

let viewModel = OSIABWebViewModel(
url: url,
self.options.toConfigurationModel().toWebViewConfiguration(),
self.options.allowOverScroll,
self.options.customUserAgent,
self.options.allowsBackForwardNavigationGestures,
uiModel: self.options.toUIModel(),
callbackHandler: self.callbackHandler
customHeaders: customHeaders,
webViewConfiguration: options.toConfigurationModel().toWebViewConfiguration(),
scrollViewBounces: options.allowOverScroll,
customUserAgent: options.customUserAgent,
backForwardNavigationGestures: options.allowsBackForwardNavigationGestures,
uiModel: options.toUIModel(),
callbackHandler: callbackHandler
)

let dismissCallback: () -> Void = { self.callbackHandler.onBrowserClosed(true) }
Expand All @@ -52,8 +58,8 @@ public class OSIABWebViewRouterAdapter: NSObject, OSIABRouter {
} else {
hostingController = OSIABWebView13Controller(rootView: .init(viewModel), dismiss: dismissCallback)
}
hostingController.modalPresentationStyle = self.options.modalPresentationStyle
hostingController.modalTransitionStyle = self.options.modalTransitionStyle
hostingController.modalPresentationStyle = options.modalPresentationStyle
hostingController.modalTransitionStyle = options.modalTransitionStyle
hostingController.presentationController?.delegate = self

completionHandler(hostingController)
Expand All @@ -66,23 +72,23 @@ private extension OSIABWebViewOptions {
/// - Returns: The `OSIABWebViewConfigurationModel` equivalent value.
func toConfigurationModel() -> OSIABWebViewConfigurationModel {
.init(
self.mediaTypesRequiringUserActionForPlayback,
self.enableViewportScale,
self.allowInLineMediaPlayback,
self.surpressIncrementalRendering
mediaTypesRequiringUserActionForPlayback,
enableViewportScale,
allowInLineMediaPlayback,
surpressIncrementalRendering
)
}

/// Converts the current value to `OSIABWebViewUIModel` equivalent.
/// - Returns: The `OSIABWebViewUIModel` equivalent value.
func toUIModel() -> OSIABWebViewUIModel {
.init(
showURL: self.showURL,
showToolbar: self.showToolbar,
toolbarPosition: self.toolbarPosition,
showNavigationButtons: self.showNavigationButtons,
leftToRight: self.leftToRight,
closeButtonText: self.closeButtonText
showURL: showURL,
showToolbar: showToolbar,
toolbarPosition: toolbarPosition,
showNavigationButtons: showNavigationButtons,
leftToRight: leftToRight,
closeButtonText: closeButtonText
)
}
}
Expand Down
Loading
Loading