@capgo/inappbrowser 7.7.2 → 7.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1294,13 +1294,38 @@ fileprivate extension WKWebViewController {
1294
1294
  // MARK: - WKUIDelegate
1295
1295
  extension WKWebViewController: WKUIDelegate {
1296
1296
  public func webView(_ webView: WKWebView, runJavaScriptAlertPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping () -> Void) {
1297
+ // Create a strong reference to the completion handler to ensure it's called
1298
+ let strongCompletionHandler = completionHandler
1299
+
1297
1300
  // Ensure UI updates are on the main thread
1298
- DispatchQueue.main.async {
1301
+ DispatchQueue.main.async { [weak self] in
1302
+ guard let self = self else {
1303
+ // View controller was deallocated
1304
+ strongCompletionHandler()
1305
+ return
1306
+ }
1307
+
1308
+ // Check if view is available and ready for presentation
1309
+ guard self.view.window != nil, !self.isBeingDismissed, !self.isMovingFromParent else {
1310
+ print("[InAppBrowser] Cannot present alert - view not in window hierarchy or being dismissed")
1311
+ strongCompletionHandler()
1312
+ return
1313
+ }
1314
+
1299
1315
  let alertController = UIAlertController(title: nil, message: message, preferredStyle: .alert)
1300
1316
  alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in
1301
- completionHandler()
1317
+ strongCompletionHandler()
1302
1318
  }))
1303
- self.present(alertController, animated: true, completion: nil)
1319
+
1320
+ // Try to present the alert
1321
+ do {
1322
+ self.present(alertController, animated: true, completion: nil)
1323
+ } catch {
1324
+ // This won't typically be triggered as present doesn't throw,
1325
+ // but adding as a safeguard
1326
+ print("[InAppBrowser] Error presenting alert: \(error)")
1327
+ strongCompletionHandler()
1328
+ }
1304
1329
  }
1305
1330
  }
1306
1331
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "7.7.2",
3
+ "version": "7.7.3",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",