Skip to content

Commit 1f16788

Browse files
sumchatteringclaude
andcommitted
SDK-31 Fix full-position IAM safe area handling
Apply safe area insets to WKWebView scrollView content for full-position in-app messages. This ensures content is not hidden behind notch, status bar, or home indicator while maintaining edge-to-edge background coverage. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7a0976d commit 1f16788

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

swift-sdk/Internal/IterableHtmlMessageViewController.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,23 @@ class IterableHtmlMessageViewController: UIViewController {
227227
let parentPosition = ViewPosition(width: view.bounds.width,
228228
height: view.bounds.height,
229229
center: view.center)
230+
let safeAreaInsets = InAppCalculations.safeAreaInsets(for: view)
230231
IterableHtmlMessageViewController.calculateWebViewPosition(webView: webView,
231-
safeAreaInsets: InAppCalculations.safeAreaInsets(for: view),
232+
safeAreaInsets: safeAreaInsets,
232233
parentPosition: parentPosition,
233234
paddingLeft: CGFloat(parameters.padding.left),
234235
paddingRight: CGFloat(parameters.padding.right),
235236
location: location)
236237
.onSuccess { [weak self] position in
238+
// Apply safe area insets to scrollView content for full position
239+
// This keeps the webView covering the full screen (edge-to-edge background)
240+
// while ensuring content is not hidden behind notch or home indicator
241+
if self?.location == .full {
242+
self?.webView.set(contentInset: safeAreaInsets)
243+
} else {
244+
self?.webView.set(contentInset: .zero)
245+
}
246+
237247
if animate {
238248
self?.animateWhileEntering(position)
239249
} else {

swift-sdk/Internal/Utilities/WebViewProtocol.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ protocol WebViewProtocol {
1717
@discardableResult func loadHTMLString(_ string: String, baseURL: URL?) -> WKNavigation?
1818
func set(position: ViewPosition)
1919
func set(navigationDelegate: WKNavigationDelegate?)
20+
func set(contentInset: UIEdgeInsets)
2021
func layoutSubviews()
2122
func calculateHeight() -> Pending<CGFloat, IterableError>
2223
}
@@ -39,7 +40,11 @@ extension WKWebView: WebViewProtocol {
3940
func set(navigationDelegate: WKNavigationDelegate?) {
4041
self.navigationDelegate = navigationDelegate
4142
}
42-
43+
44+
func set(contentInset: UIEdgeInsets) {
45+
scrollView.contentInset = contentInset
46+
}
47+
4348
func calculateHeight() -> Pending<CGFloat, IterableError> {
4449
let fulfill = Fulfill<CGFloat, IterableError>()
4550

tests/common/MockWebView.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,20 @@ class MockWebView: WebViewProtocol {
2222
}
2323

2424
func set(navigationDelegate _: WKNavigationDelegate?) {}
25-
25+
26+
func set(contentInset: UIEdgeInsets) {
27+
self.contentInset = contentInset
28+
}
29+
2630
func layoutSubviews() {}
2731

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

3236
var position: ViewPosition = ViewPosition()
33-
37+
var contentInset: UIEdgeInsets = .zero
38+
3439
private var height: CGFloat
3540

3641
init(height: CGFloat) {

0 commit comments

Comments
 (0)