Skip to content

Commit

Permalink
added dismiss() method to KlaviyoWebViewDelegate
Browse files Browse the repository at this point in the history
  • Loading branch information
ab1470 committed Jan 22, 2025
1 parent 044ae38 commit 4741810
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ class KlaviyoWebViewController: UIViewController, WKUIDelegate, KlaviyoWebViewDe
loadUrl()
}

@MainActor
func dismiss() {
dismiss(animated: true)
}

// MARK: - Scripts

/// Configures the scripts to be injected into the website when the website loads.
Expand Down
7 changes: 7 additions & 0 deletions Sources/KlaviyoUI/KlaviyoWebView/KlaviyoWebViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public protocol KlaviyoWebViewDelegate: AnyObject {

@MainActor
func evaluateJavaScript(_ script: String) async throws -> Any

@MainActor
func dismiss()
}

@_spi(KlaviyoPrivate)
Expand Down Expand Up @@ -48,6 +51,10 @@ public class KlaviyoWebViewModel: KlaviyoWebViewModeling {
if message.name == "closeHandler" {
// TODO: handle close button tap
print("user tapped close button")

Task {
await delegate?.dismiss()
}
}
}
}

0 comments on commit 4741810

Please sign in to comment.