Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ CI.swift
*.mdb
.build/arm64-apple-macosx/debug/IterableSDK.build/output-file-map.json
.build
.mcp.json
12 changes: 11 additions & 1 deletion swift-sdk/Internal/IterableHtmlMessageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,23 @@ class IterableHtmlMessageViewController: UIViewController {
let parentPosition = ViewPosition(width: view.bounds.width,
height: view.bounds.height,
center: view.center)
let safeAreaInsets = InAppCalculations.safeAreaInsets(for: view)
IterableHtmlMessageViewController.calculateWebViewPosition(webView: webView,
safeAreaInsets: InAppCalculations.safeAreaInsets(for: view),
safeAreaInsets: safeAreaInsets,
parentPosition: parentPosition,
paddingLeft: CGFloat(parameters.padding.left),
paddingRight: CGFloat(parameters.padding.right),
location: location)
.onSuccess { [weak self] position in
// Apply safe area insets to scrollView content for full position
// This keeps the webView covering the full screen (edge-to-edge background)
// while ensuring content is not hidden behind notch or home indicator
if self?.location == .full {
self?.webView.set(contentInset: safeAreaInsets)
} else {
self?.webView.set(contentInset: .zero)
}

if animate {
self?.animateWhileEntering(position)
} else {
Expand Down
7 changes: 6 additions & 1 deletion swift-sdk/Internal/Utilities/WebViewProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ protocol WebViewProtocol {
@discardableResult func loadHTMLString(_ string: String, baseURL: URL?) -> WKNavigation?
func set(position: ViewPosition)
func set(navigationDelegate: WKNavigationDelegate?)
func set(contentInset: UIEdgeInsets)
func layoutSubviews()
func calculateHeight() -> Pending<CGFloat, IterableError>
}
Expand All @@ -39,7 +40,11 @@ extension WKWebView: WebViewProtocol {
func set(navigationDelegate: WKNavigationDelegate?) {
self.navigationDelegate = navigationDelegate
}


func set(contentInset: UIEdgeInsets) {
scrollView.contentInset = contentInset
}

func calculateHeight() -> Pending<CGFloat, IterableError> {
let fulfill = Fulfill<CGFloat, IterableError>()

Expand Down
9 changes: 7 additions & 2 deletions tests/common/MockWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,20 @@ class MockWebView: WebViewProtocol {
}

func set(navigationDelegate _: WKNavigationDelegate?) {}


func set(contentInset: UIEdgeInsets) {
self.contentInset = contentInset
}

func layoutSubviews() {}

func calculateHeight() -> Pending<CGFloat, IterableError> {
Fulfill<CGFloat, IterableError>(value: height)
}

var position: ViewPosition = ViewPosition()

var contentInset: UIEdgeInsets = .zero

private var height: CGFloat

init(height: CGFloat) {
Expand Down
Loading