Skip to content

Commit

Permalink
fix(ios): Present js alert on top of the presented VC (#5282)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Nov 30, 2021
1 parent 9be627d commit a53d236
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ios/Capacitor/Capacitor/WebViewDelegationHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,15 @@ internal class WebViewDelegationHandler: NSObject, WKNavigationDelegate, WKUIDel
// MARK: - WKUIDelegate

public func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void) {
guard let viewController = bridge?.viewController else {
guard var viewController = bridge?.viewController else {
completionHandler()
return
}

if let presentedVC = viewController.presentedViewController, !presentedVC.isBeingDismissed {
viewController = presentedVC
}

let alertController = UIAlertController(title: nil, message: message, preferredStyle: .alert)

alertController.addAction(UIAlertAction(title: "Ok", style: .default, handler: { (_) in
Expand Down

0 comments on commit a53d236

Please sign in to comment.