@capgo/inappbrowser 8.1.4 → 8.1.6

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.
@@ -50,7 +50,7 @@ import org.json.JSONObject;
50
50
  )
51
51
  public class InAppBrowserPlugin extends Plugin implements WebViewDialog.PermissionHandler {
52
52
 
53
- private final String pluginVersion = "8.1.4";
53
+ private final String pluginVersion = "8.1.6";
54
54
 
55
55
  public static final String CUSTOM_TAB_PACKAGE_NAME = "com.android.chrome"; // Change when in stable
56
56
  private CustomTabsClient customTabsClient;
@@ -404,6 +404,8 @@ public class WebViewDialog extends Dialog {
404
404
  applyInsets();
405
405
 
406
406
  _webView.addJavascriptInterface(new JavaScriptInterface(), "AndroidInterface");
407
+ // Provide window.mobileApp at document start via native interface
408
+ _webView.addJavascriptInterface(new JavaScriptInterface(), "mobileApp");
407
409
  _webView.addJavascriptInterface(new PreShowScriptInterface(), "PreShowScriptInterface");
408
410
  _webView.addJavascriptInterface(new PrintInterface(this._context, _webView), "PrintInterface");
409
411
  _webView.getSettings().setJavaScriptEnabled(true);
@@ -1286,27 +1288,27 @@ public class WebViewDialog extends Dialog {
1286
1288
  String script = String.format(
1287
1289
  """
1288
1290
  (function() {
1289
- if (window.AndroidInterface) {
1290
- // Create mobileApp object for backward compatibility
1291
- if (!window.mobileApp) {
1292
- window.mobileApp = {
1293
- postMessage: function(message) {
1294
- try {
1295
- var msg = typeof message === 'string' ? message : JSON.stringify(message);
1296
- window.AndroidInterface.postMessage(msg);
1297
- } catch(e) {
1298
- console.error('Error in mobileApp.postMessage:', e);
1299
- }
1300
- },
1301
- close: function() {
1302
- try {
1303
- window.AndroidInterface.close();
1304
- } catch(e) {
1305
- console.error('Error in mobileApp.close:', e);
1306
- }
1307
- }%s
1308
- };
1309
- }
1291
+ // Prefer AndroidInterface when available, otherwise fall back to native window.mobileApp
1292
+ var nativeBridge = window.AndroidInterface || window.mobileApp;
1293
+ if (nativeBridge) {
1294
+ // Wrap native bridge to normalize behavior (stringify objects, expose close/hide/show)
1295
+ window.mobileApp = {
1296
+ postMessage: function(message) {
1297
+ try {
1298
+ var msg = typeof message === 'string' ? message : JSON.stringify(message);
1299
+ nativeBridge.postMessage(msg);
1300
+ } catch(e) {
1301
+ console.error('Error in mobileApp.postMessage:', e);
1302
+ }
1303
+ },
1304
+ close: function() {
1305
+ try {
1306
+ nativeBridge.close();
1307
+ } catch(e) {
1308
+ console.error('Error in mobileApp.close:', e);
1309
+ }
1310
+ }%s
1311
+ };
1310
1312
  }
1311
1313
  // Override window.print function to use our PrintInterface
1312
1314
  if (window.PrintInterface) {
@@ -28,7 +28,7 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
28
28
  case aware = "AWARE"
29
29
  case fakeVisible = "FAKE_VISIBLE"
30
30
  }
31
- private let pluginVersion: String = "8.1.4"
31
+ private let pluginVersion: String = "8.1.6"
32
32
  public let identifier = "InAppBrowserPlugin"
33
33
  public let jsName = "InAppBrowser"
34
34
  public let pluginMethods: [CAPPluginMethod] = [
@@ -57,6 +57,9 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
57
57
  var isHidden = false
58
58
  var invisibilityMode: InvisibilityMode = .aware
59
59
  var webViewController: WKWebViewController?
60
+ private weak var presentationContainerView: UIView?
61
+ private var presentationContainerWasInteractive = true
62
+ private var presentationContainerPreviousAlpha: CGFloat = 1
60
63
  private var closeModalTitle: String?
61
64
  private var closeModalDescription: String?
62
65
  private var closeModalOk: String?
@@ -829,6 +832,15 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
829
832
  if let navController = self.navigationWebViewController, navController.presentingViewController != nil {
830
833
  navController.view.isHidden = true
831
834
  navController.view.isUserInteractionEnabled = false
835
+ if let containerView = navController.view.superview {
836
+ if self.presentationContainerView == nil || self.presentationContainerView !== containerView {
837
+ self.presentationContainerView = containerView
838
+ self.presentationContainerWasInteractive = containerView.isUserInteractionEnabled
839
+ self.presentationContainerPreviousAlpha = containerView.alpha
840
+ }
841
+ containerView.isUserInteractionEnabled = false
842
+ containerView.alpha = 0
843
+ }
832
844
  }
833
845
 
834
846
  if !self.attachWebViewToWindow(webView) {
@@ -843,6 +855,13 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
843
855
  if let navController = self.navigationWebViewController {
844
856
  navController.view.isHidden = false
845
857
  navController.view.isUserInteractionEnabled = true
858
+ if let containerView = self.presentationContainerView {
859
+ containerView.isUserInteractionEnabled = self.presentationContainerWasInteractive
860
+ containerView.alpha = self.presentationContainerPreviousAlpha
861
+ self.presentationContainerView = nil
862
+ self.presentationContainerWasInteractive = true
863
+ self.presentationContainerPreviousAlpha = 1
864
+ }
846
865
 
847
866
  if navController.presentingViewController == nil {
848
867
  self.bridge?.viewController?.present(navController, animated: true, completion: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "8.1.4",
3
+ "version": "8.1.6",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",