@capgo/inappbrowser 7.12.1 → 7.13.0

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.
package/README.md CHANGED
@@ -551,6 +551,7 @@ Reload the current web page.
551
551
  | **`textZoom`** | <code>number</code> | textZoom: sets the text zoom of the page in percent. Allows users to increase or decrease the text size for better readability. | <code>100</code> | 7.6.0 |
552
552
  | **`preventDeeplink`** | <code>boolean</code> | preventDeeplink: if true, the deeplink will not be opened, if false the deeplink will be opened when clicked on the link. on IOS each schema need to be added to info.plist file under LSApplicationQueriesSchemes when false to make it work. | <code>false</code> | 0.1.0 |
553
553
  | **`authorizedAppLinks`** | <code>string[]</code> | List of URL base patterns that should be treated as authorized App Links, Android only. Only links starting with any of these base URLs will be opened in the InAppBrowser. | <code>[]</code> | 7.12.0 |
554
+ | **`enableGooglePaySupport`** | <code>boolean</code> | enableGooglePaySupport: if true, enables support for Google Pay popups and Payment Request API. This fixes OR_BIBED_15 errors by allowing popup windows and configuring Cross-Origin-Opener-Policy. Only enable this if you need Google Pay functionality as it allows popup windows. When enabled: - Allows popup windows for Google Pay authentication - Sets proper CORS headers for Payment Request API - Enables multiple window support in WebView - Configures secure context for payment processing | <code>false</code> | 7.13.0 |
554
555
 
555
556
 
556
557
  #### Headers
@@ -752,6 +752,11 @@ public class InAppBrowserPlugin
752
752
  Log.d("InAppBrowserPlugin", "No authorized app links provided.");
753
753
  }
754
754
 
755
+ // Set Google Pay support option
756
+ options.setEnableGooglePaySupport(
757
+ Boolean.TRUE.equals(call.getBoolean("enableGooglePaySupport", false))
758
+ );
759
+
755
760
  this.getActivity()
756
761
  .runOnUiThread(
757
762
  new Runnable() {
@@ -180,6 +180,7 @@ public class Options {
180
180
  private int textZoom = 100; // Default text zoom is 100%
181
181
  private boolean preventDeeplink = false;
182
182
  private List<String> authorizedAppLinks = new ArrayList<>();
183
+ private boolean enableGooglePaySupport = false;
183
184
 
184
185
  public int getTextZoom() {
185
186
  return textZoom;
@@ -434,4 +435,12 @@ public class Options {
434
435
  public void setAuthorizedAppLinks(List<String> authorizedAppLinks) {
435
436
  this.authorizedAppLinks = authorizedAppLinks;
436
437
  }
438
+
439
+ public boolean getEnableGooglePaySupport() {
440
+ return enableGooglePaySupport;
441
+ }
442
+
443
+ public void setEnableGooglePaySupport(boolean enableGooglePaySupport) {
444
+ this.enableGooglePaySupport = enableGooglePaySupport;
445
+ }
437
446
  }
@@ -400,6 +400,27 @@ public class WebViewDialog extends Dialog {
400
400
  _webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
401
401
  _webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
402
402
 
403
+ // Enhanced settings for Google Pay and Payment Request API support (only when enabled)
404
+ if (_options.getEnableGooglePaySupport()) {
405
+ Log.d("InAppBrowser", "Enabling Google Pay support features");
406
+ _webView
407
+ .getSettings()
408
+ .setMixedContentMode(
409
+ android.webkit.WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
410
+ );
411
+ _webView.getSettings().setSupportMultipleWindows(true);
412
+ _webView.getSettings().setGeolocationEnabled(true);
413
+
414
+ // Ensure secure context for Payment Request API
415
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
416
+ _webView
417
+ .getSettings()
418
+ .setMixedContentMode(
419
+ android.webkit.WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE
420
+ );
421
+ }
422
+ }
423
+
403
424
  // Set web view background color
404
425
  int backgroundColor = _options.getBackgroundColor().equals("white")
405
426
  ? Color.WHITE
@@ -850,6 +871,88 @@ public class WebViewDialog extends Dialog {
850
871
  injectDatePickerFixes();
851
872
  }
852
873
  }
874
+
875
+ // Support for Google Pay and popup windows (critical for OR_BIBED_15 fix)
876
+ @Override
877
+ public boolean onCreateWindow(
878
+ WebView view,
879
+ boolean isDialog,
880
+ boolean isUserGesture,
881
+ android.os.Message resultMsg
882
+ ) {
883
+ Log.d(
884
+ "InAppBrowser",
885
+ "onCreateWindow called - isUserGesture: " +
886
+ isUserGesture +
887
+ ", GooglePaySupport: " +
888
+ _options.getEnableGooglePaySupport()
889
+ );
890
+
891
+ // Only handle popup windows if Google Pay support is enabled
892
+ if (_options.getEnableGooglePaySupport() && isUserGesture) {
893
+ // Create a new WebView for the popup
894
+ WebView popupWebView = new WebView(activity);
895
+ popupWebView.getSettings().setJavaScriptEnabled(true);
896
+ popupWebView
897
+ .getSettings()
898
+ .setJavaScriptCanOpenWindowsAutomatically(true);
899
+ popupWebView.getSettings().setSupportMultipleWindows(true);
900
+
901
+ // Set WebViewClient to handle URL loading and closing
902
+ popupWebView.setWebViewClient(
903
+ new WebViewClient() {
904
+ @Override
905
+ public boolean shouldOverrideUrlLoading(
906
+ WebView view,
907
+ String url
908
+ ) {
909
+ Log.d("InAppBrowser", "Popup WebView loading URL: " + url);
910
+
911
+ // Handle Google Pay result URLs or close conditions
912
+ if (
913
+ url.contains("google.com/pay") ||
914
+ url.contains("close") ||
915
+ url.contains("cancel")
916
+ ) {
917
+ Log.d(
918
+ "InAppBrowser",
919
+ "Closing popup for Google Pay result"
920
+ );
921
+ // Notify the parent WebView and close popup
922
+ activity.runOnUiThread(() -> {
923
+ try {
924
+ if (popupWebView.getParent() != null) {
925
+ ((ViewGroup) popupWebView.getParent()).removeView(
926
+ popupWebView
927
+ );
928
+ }
929
+ popupWebView.destroy();
930
+ } catch (Exception e) {
931
+ Log.e(
932
+ "InAppBrowser",
933
+ "Error closing popup: " + e.getMessage()
934
+ );
935
+ }
936
+ });
937
+ return true;
938
+ }
939
+ return false;
940
+ }
941
+ }
942
+ );
943
+
944
+ // Set up the popup WebView transport
945
+ WebView.WebViewTransport transport =
946
+ (WebView.WebViewTransport) resultMsg.obj;
947
+ transport.setWebView(popupWebView);
948
+ resultMsg.sendToTarget();
949
+
950
+ Log.d("InAppBrowser", "Created popup window for Google Pay");
951
+ return true;
952
+ }
953
+
954
+ return false;
955
+ }
853
956
  }
854
957
  );
855
958
 
@@ -877,6 +980,12 @@ public class WebViewDialog extends Dialog {
877
980
  _webView.post(() -> {
878
981
  if (_webView != null) {
879
982
  injectJavaScriptInterface();
983
+
984
+ // Inject Google Pay support enhancements if enabled
985
+ if (_options.getEnableGooglePaySupport()) {
986
+ injectGooglePayPolyfills();
987
+ }
988
+
880
989
  Log.d(
881
990
  "InAppBrowser",
882
991
  "JavaScript interface injected early after URL load"
@@ -1215,6 +1324,113 @@ public class WebViewDialog extends Dialog {
1215
1324
  }
1216
1325
  }
1217
1326
 
1327
+ /**
1328
+ * Injects JavaScript polyfills and enhancements for Google Pay support
1329
+ * Helps resolve OR_BIBED_15 errors by ensuring proper cross-origin handling
1330
+ */
1331
+ private void injectGooglePayPolyfills() {
1332
+ if (_webView == null) {
1333
+ Log.w(
1334
+ "InAppBrowser",
1335
+ "Cannot inject Google Pay polyfills - WebView is null"
1336
+ );
1337
+ return;
1338
+ }
1339
+
1340
+ try {
1341
+ String googlePayScript =
1342
+ """
1343
+ (function() {
1344
+ console.log('[InAppBrowser] Injecting Google Pay support enhancements');
1345
+
1346
+ // Enhance window.open to work better with Google Pay popups
1347
+ const originalWindowOpen = window.open;
1348
+ window.open = function(url, target, features) {
1349
+ console.log('[InAppBrowser] Enhanced window.open called:', url, target, features);
1350
+
1351
+ // For Google Pay URLs, ensure they open in a new context
1352
+ if (url && (url.includes('google.com/pay') || url.includes('accounts.google.com'))) {
1353
+ console.log('[InAppBrowser] Google Pay popup detected, using enhanced handling');
1354
+ // Let the native WebView handle this via onCreateWindow
1355
+ return originalWindowOpen.call(window, url, '_blank', features);
1356
+ }
1357
+
1358
+ return originalWindowOpen.call(window, url, target, features);
1359
+ };
1360
+
1361
+ // Ensure proper Payment Request API context
1362
+ if (window.PaymentRequest) {
1363
+ console.log('[InAppBrowser] Payment Request API available');
1364
+
1365
+ // Wrap PaymentRequest constructor to add better error handling
1366
+ const OriginalPaymentRequest = window.PaymentRequest;
1367
+ window.PaymentRequest = function(methodData, details, options) {
1368
+ console.log('[InAppBrowser] PaymentRequest created with enhanced error handling');
1369
+ const request = new OriginalPaymentRequest(methodData, details, options);
1370
+
1371
+ // Override show method to handle popup blocking issues
1372
+ const originalShow = request.show;
1373
+ request.show = function() {
1374
+ console.log('[InAppBrowser] PaymentRequest.show() called');
1375
+ return originalShow.call(this).catch((error) => {
1376
+ console.error('[InAppBrowser] PaymentRequest error:', error);
1377
+ if (error.name === 'SecurityError' || error.message.includes('popup')) {
1378
+ console.log('[InAppBrowser] Attempting to handle popup blocking issue');
1379
+ }
1380
+ throw error;
1381
+ });
1382
+ };
1383
+
1384
+ return request;
1385
+ };
1386
+
1387
+ // Copy static methods
1388
+ Object.setPrototypeOf(window.PaymentRequest, OriginalPaymentRequest);
1389
+ Object.defineProperty(window.PaymentRequest, 'prototype', {
1390
+ value: OriginalPaymentRequest.prototype
1391
+ });
1392
+ }
1393
+
1394
+ // Add meta tag to ensure proper cross-origin handling if not present
1395
+ if (!document.querySelector('meta[http-equiv="Cross-Origin-Opener-Policy"]')) {
1396
+ const meta = document.createElement('meta');
1397
+ meta.setAttribute('http-equiv', 'Cross-Origin-Opener-Policy');
1398
+ meta.setAttribute('content', 'same-origin-allow-popups');
1399
+ if (document.head) {
1400
+ document.head.appendChild(meta);
1401
+ console.log('[InAppBrowser] Added Cross-Origin-Opener-Policy meta tag');
1402
+ }
1403
+ }
1404
+
1405
+ console.log('[InAppBrowser] Google Pay support enhancements complete');
1406
+ })();
1407
+ """;
1408
+
1409
+ _webView.post(() -> {
1410
+ if (_webView != null) {
1411
+ try {
1412
+ _webView.evaluateJavascript(googlePayScript, result -> {
1413
+ Log.d(
1414
+ "InAppBrowser",
1415
+ "Google Pay polyfills injected successfully"
1416
+ );
1417
+ });
1418
+ } catch (Exception e) {
1419
+ Log.e(
1420
+ "InAppBrowser",
1421
+ "Error injecting Google Pay polyfills: " + e.getMessage()
1422
+ );
1423
+ }
1424
+ }
1425
+ });
1426
+ } catch (Exception e) {
1427
+ Log.e(
1428
+ "InAppBrowser",
1429
+ "Error preparing Google Pay polyfills: " + e.getMessage()
1430
+ );
1431
+ }
1432
+ }
1433
+
1218
1434
  private void injectPreShowScript() {
1219
1435
  // String script =
1220
1436
  // "import('https://unpkg.com/darkreader@4.9.89/darkreader.js').then(() => {DarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 });window.PreLoadScriptInterface.finished()})";
@@ -2580,6 +2796,11 @@ public class WebViewDialog extends Dialog {
2580
2796
  }
2581
2797
  super.doUpdateVisitedHistory(view, url, isReload);
2582
2798
  injectJavaScriptInterface();
2799
+
2800
+ // Inject Google Pay polyfills if enabled
2801
+ if (_options.getEnableGooglePaySupport()) {
2802
+ injectGooglePayPolyfills();
2803
+ }
2583
2804
  }
2584
2805
 
2585
2806
  @Override
@@ -2696,6 +2917,11 @@ public class WebViewDialog extends Dialog {
2696
2917
 
2697
2918
  _options.getCallbacks().pageLoaded();
2698
2919
  injectJavaScriptInterface();
2920
+
2921
+ // Inject Google Pay polyfills if enabled
2922
+ if (_options.getEnableGooglePaySupport()) {
2923
+ injectGooglePayPolyfills();
2924
+ }
2699
2925
  }
2700
2926
 
2701
2927
  @Override
package/dist/docs.json CHANGED
@@ -1081,6 +1081,26 @@
1081
1081
  "docs": "List of URL base patterns that should be treated as authorized App Links, Android only.\nOnly links starting with any of these base URLs will be opened in the InAppBrowser.",
1082
1082
  "complexTypes": [],
1083
1083
  "type": "string[] | undefined"
1084
+ },
1085
+ {
1086
+ "name": "enableGooglePaySupport",
1087
+ "tags": [
1088
+ {
1089
+ "text": "7.13.0",
1090
+ "name": "since"
1091
+ },
1092
+ {
1093
+ "text": "false",
1094
+ "name": "default"
1095
+ },
1096
+ {
1097
+ "text": "enableGooglePaySupport: true\nTest URL: https://developers.google.com/pay/api/web/guides/tutorial",
1098
+ "name": "example"
1099
+ }
1100
+ ],
1101
+ "docs": "enableGooglePaySupport: if true, enables support for Google Pay popups and Payment Request API.\nThis fixes OR_BIBED_15 errors by allowing popup windows and configuring Cross-Origin-Opener-Policy.\nOnly enable this if you need Google Pay functionality as it allows popup windows.\n\nWhen enabled:\n- Allows popup windows for Google Pay authentication\n- Sets proper CORS headers for Payment Request API\n- Enables multiple window support in WebView\n- Configures secure context for payment processing",
1102
+ "complexTypes": [],
1103
+ "type": "boolean | undefined"
1084
1104
  }
1085
1105
  ]
1086
1106
  },
@@ -416,6 +416,24 @@ export interface OpenWebViewOptions {
416
416
  * @default []
417
417
  */
418
418
  authorizedAppLinks?: string[];
419
+ /**
420
+ * enableGooglePaySupport: if true, enables support for Google Pay popups and Payment Request API.
421
+ * This fixes OR_BIBED_15 errors by allowing popup windows and configuring Cross-Origin-Opener-Policy.
422
+ * Only enable this if you need Google Pay functionality as it allows popup windows.
423
+ *
424
+ * When enabled:
425
+ * - Allows popup windows for Google Pay authentication
426
+ * - Sets proper CORS headers for Payment Request API
427
+ * - Enables multiple window support in WebView
428
+ * - Configures secure context for payment processing
429
+ *
430
+ * @since 7.13.0
431
+ * @default false
432
+ * @example
433
+ * enableGooglePaySupport: true
434
+ * Test URL: https://developers.google.com/pay/api/web/guides/tutorial
435
+ */
436
+ enableGooglePaySupport?: boolean;
419
437
  }
420
438
  export interface InAppBrowserPlugin {
421
439
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAuBA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AACD,MAAM,CAAN,IAAY,WAqBX;AArBD,WAAY,WAAW;IACrB;;;OAGG;IACH,oCAAqB,CAAA;IACrB;;;OAGG;IACH,kCAAmB,CAAA;IACnB;;;OAGG;IACH,wCAAyB,CAAA;IACzB;;;OAGG;IACH,8BAAe,CAAA;AACjB,CAAC,EArBW,WAAW,KAAX,WAAW,QAqBtB","sourcesContent":["import type { PluginListenerHandle } from \"@capacitor/core\";\n\nexport interface UrlEvent {\n /**\n * Emit when the url changes\n *\n * @since 0.0.1\n */\n url: string;\n}\nexport interface BtnEvent {\n /**\n * Emit when a button is clicked.\n *\n * @since 0.0.1\n */\n url: string;\n}\n\nexport type UrlChangeListener = (state: UrlEvent) => void;\nexport type ConfirmBtnListener = (state: BtnEvent) => void;\nexport type ButtonNearListener = (state: object) => void;\n\nexport enum BackgroundColor {\n WHITE = \"white\",\n BLACK = \"black\",\n}\nexport enum ToolBarType {\n /**\n * Shows a simple toolbar with just a close button and share button\n * @since 0.1.0\n */\n ACTIVITY = \"activity\",\n /**\n * Shows a simple toolbar with just a close button\n * @since 7.6.8\n */\n COMPACT = \"compact\",\n /**\n * Shows a full navigation toolbar with back/forward buttons\n * @since 0.1.0\n */\n NAVIGATION = \"navigation\",\n /**\n * Shows no toolbar\n * @since 0.1.0\n */\n BLANK = \"blank\",\n}\n\nexport interface Headers {\n [key: string]: string;\n}\n\nexport interface GetCookieOptions {\n url: string;\n includeHttpOnly?: boolean;\n}\n\nexport interface ClearCookieOptions {\n url: string;\n}\n\nexport interface Credentials {\n username: string;\n password: string;\n}\n\nexport interface OpenOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n */\n isPresentAfterPageLoad?: boolean;\n /**\n * if true the deeplink will not be opened, if false the deeplink will be opened when clicked on the link\n * @since 0.1.0\n */\n preventDeeplink?: boolean;\n}\n\nexport interface DisclaimerOptions {\n /**\n * Title of the disclaimer dialog\n * @default \"Title\"\n */\n title: string;\n /**\n * Message shown in the disclaimer dialog\n * @default \"Message\"\n */\n message: string;\n /**\n * Text for the confirm button\n * @default \"Confirm\"\n */\n confirmBtn: string;\n /**\n * Text for the cancel button\n * @default \"Cancel\"\n */\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n * @example \"https://capgo.app\"\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n * @example\n * headers: {\n * 'Custom-Header': 'test-value',\n * 'Authorization': 'Bearer test-token'\n * }\n * Test URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/\n */\n headers?: Headers;\n /**\n * Credentials to send with the request and all subsequent requests for the same host.\n * @since 6.1.0\n * @example\n * credentials: {\n * username: 'test-user',\n * password: 'test-pass'\n * }\n * Test URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/\n */\n credentials?: Credentials;\n /**\n * materialPicker: if true, uses Material Design theme for date and time pickers on Android.\n * This improves the appearance of HTML date inputs to use modern Material Design UI instead of the old style pickers.\n * @since 7.4.1\n * @default false\n * @example\n * materialPicker: true\n * Test URL: https://show-picker.glitch.me/demo.html\n */\n materialPicker?: boolean;\n /**\n * JavaScript Interface:\n * The webview automatically injects a JavaScript interface providing:\n * - `window.mobileApp.close()`: Closes the webview from JavaScript\n * - `window.mobileApp.postMessage(obj)`: Sends a message to the app (listen via \"messageFromWebview\" event)\n *\n * @example\n * // In your webpage loaded in the webview:\n * document.getElementById('closeBtn').addEventListener('click', () => {\n * window.mobileApp.close();\n * });\n *\n * // Send data to the app\n * window.mobileApp.postMessage({ action: 'login', data: { user: 'test' }});\n *\n * @since 6.10.0\n */\n jsInterface?: never; // This property doesn't exist, it's just for documentation\n /**\n * Share options for the webview. When provided, shows a disclaimer dialog before sharing content.\n * This is useful for:\n * - Warning users about sharing sensitive information\n * - Getting user consent before sharing\n * - Explaining what will be shared\n * - Complying with privacy regulations\n *\n * Note: shareSubject is required when using shareDisclaimer\n * @since 0.1.0\n * @example\n * shareDisclaimer: {\n * title: 'Disclaimer',\n * message: 'This is a test disclaimer',\n * confirmBtn: 'Accept',\n * cancelBtn: 'Decline'\n * }\n * Test URL: https://capgo.app\n */\n shareDisclaimer?: DisclaimerOptions;\n /**\n * Toolbar type determines the appearance and behavior of the browser's toolbar\n * - \"activity\": Shows a simple toolbar with just a close button and share button\n * - \"navigation\": Shows a full navigation toolbar with back/forward buttons\n * - \"blank\": Shows no toolbar\n * - \"\": Default toolbar with close button\n * @since 0.1.0\n * @default ToolBarType.DEFAULT\n * @example\n * toolbarType: ToolBarType.ACTIVITY,\n * title: 'Activity Toolbar Test'\n * Test URL: https://capgo.app\n */\n toolbarType?: ToolBarType;\n /**\n * Subject text for sharing. Required when using shareDisclaimer.\n * This text will be used as the subject line when sharing content.\n * @since 0.1.0\n * @example \"Share this page\"\n */\n shareSubject?: string;\n /**\n * Title of the browser\n * @since 0.1.0\n * @default 'New Window'\n * @example \"Camera Test\"\n */\n title?: string;\n /**\n * Background color of the browser\n * @since 0.1.0\n * @default BackgroundColor.BLACK\n */\n backgroundColor?: BackgroundColor;\n /**\n * If true, active the native navigation within the webview, Android only\n * @default false\n * @example\n * activeNativeNavigationForWebview: true,\n * disableGoBackOnNativeApplication: true\n * Test URL: https://capgo.app\n */\n activeNativeNavigationForWebview?: boolean;\n /**\n * Disable the possibility to go back on native application,\n * useful to force user to stay on the webview, Android only\n * @default false\n * @example\n * disableGoBackOnNativeApplication: true\n * Test URL: https://capgo.app\n */\n disableGoBackOnNativeApplication?: boolean;\n /**\n * Open url in a new window fullscreen\n * isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n * @default false\n * @example\n * isPresentAfterPageLoad: true,\n * preShowScript: \"await import('https://unpkg.com/darkreader@4.9.89/darkreader.js');\\nDarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 });\"\n * Test URL: https://capgo.app\n */\n isPresentAfterPageLoad?: boolean;\n /**\n * Whether the website in the webview is inspectable or not, ios only\n * @default false\n */\n isInspectable?: boolean;\n /**\n * Whether the webview opening is animated or not, ios only\n * @default true\n */\n isAnimated?: boolean;\n /**\n * Shows a reload button that reloads the web page\n * @since 1.0.15\n * @default false\n * @example\n * showReloadButton: true\n * Test URL: https://capgo.app\n */\n showReloadButton?: boolean;\n /**\n * CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately.\n * @since 1.1.0\n * @default false\n * @example\n * closeModal: true,\n * closeModalTitle: 'Close Window',\n * closeModalDescription: 'Are you sure you want to close?',\n * closeModalOk: 'Yes, close',\n * closeModalCancel: 'No, stay'\n * Test URL: https://capgo.app\n */\n closeModal?: boolean;\n /**\n * CloseModalTitle: title of the confirm when user clicks on close button\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalTitle?: string;\n /**\n * CloseModalDescription: description of the confirm when user clicks on close button\n * @since 1.1.0\n * @default 'Are you sure you want to close this window?'\n */\n closeModalDescription?: string;\n /**\n * CloseModalOk: text of the confirm button when user clicks on close button\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalOk?: string;\n /**\n * CloseModalCancel: text of the cancel button when user clicks on close button\n * @since 1.1.0\n * @default 'Cancel'\n */\n closeModalCancel?: string;\n /**\n * visibleTitle: if true the website title would be shown else shown empty\n * @since 1.2.5\n * @default true\n */\n visibleTitle?: boolean;\n /**\n * toolbarColor: color of the toolbar in hex format\n * @since 1.2.5\n * @default '#ffffff'\n * @example\n * toolbarColor: '#FF5733'\n * Test URL: https://capgo.app\n */\n toolbarColor?: string;\n /**\n * toolbarTextColor: color of the buttons and title in the toolbar in hex format\n * When set, it overrides the automatic light/dark mode detection for text color\n * @since 6.10.0\n * @default calculated based on toolbarColor brightness\n * @example\n * toolbarTextColor: '#FFFFFF'\n * Test URL: https://capgo.app\n */\n toolbarTextColor?: string;\n /**\n * showArrow: if true an arrow would be shown instead of cross for closing the window\n * @since 1.2.5\n * @default false\n * @example\n * showArrow: true\n * Test URL: https://capgo.app\n */\n showArrow?: boolean;\n /**\n * ignoreUntrustedSSLError: if true, the webview will ignore untrusted SSL errors allowing the user to view the website.\n * @since 6.1.0\n * @default false\n */\n ignoreUntrustedSSLError?: boolean;\n /**\n * preShowScript: if isPresentAfterPageLoad is true and this variable is set the plugin will inject a script before showing the browser.\n * This script will be run in an async context. The plugin will wait for the script to finish (max 10 seconds)\n * @since 6.6.0\n * @example\n * preShowScript: \"await import('https://unpkg.com/darkreader@4.9.89/darkreader.js');\\nDarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 });\"\n * Test URL: https://capgo.app\n */\n preShowScript?: string;\n /**\n * proxyRequests is a regex expression. Please see [this pr](https://github.com/Cap-go/capacitor-inappbrowser/pull/222) for more info. (Android only)\n * @since 6.9.0\n */\n proxyRequests?: string;\n /**\n * buttonNearDone allows for a creation of a custom button near the done/close button.\n * The button is only shown when toolbarType is not \"activity\", \"navigation\", or \"blank\".\n *\n * For Android:\n * - iconType must be \"asset\"\n * - icon path should be in the public folder (e.g. \"monkey.svg\")\n * - width and height are optional, defaults to 48dp\n * - button is positioned at the end of toolbar with 8dp margin\n *\n * For iOS:\n * - iconType can be \"sf-symbol\" or \"asset\"\n * - for sf-symbol, icon should be the symbol name\n * - for asset, icon should be the asset name\n * @since 6.7.0\n * @example\n * buttonNearDone: {\n * ios: {\n * iconType: 'sf-symbol',\n * icon: 'star.fill'\n * },\n * android: {\n * iconType: 'asset',\n * icon: 'public/monkey.svg',\n * width: 24,\n * height: 24\n * }\n * }\n * Test URL: https://capgo.app\n */\n buttonNearDone?: {\n ios: {\n iconType: \"sf-symbol\" | \"asset\";\n icon: string;\n };\n android: {\n iconType: \"asset\" | \"vector\";\n icon: string;\n width?: number;\n height?: number;\n };\n };\n /**\n * textZoom: sets the text zoom of the page in percent.\n * Allows users to increase or decrease the text size for better readability.\n * @since 7.6.0\n * @default 100\n * @example\n * textZoom: 120\n * Test URL: https://capgo.app\n */\n textZoom?: number;\n /**\n * preventDeeplink: if true, the deeplink will not be opened, if false the deeplink will be opened when clicked on the link. on IOS each schema need to be added to info.plist file under LSApplicationQueriesSchemes when false to make it work.\n * @since 0.1.0\n * @default false\n * @example\n * preventDeeplink: true\n * Test URL: https://aasa-tester.capgo.app/\n */\n preventDeeplink?: boolean;\n\n /**\n * List of URL base patterns that should be treated as authorized App Links, Android only.\n * Only links starting with any of these base URLs will be opened in the InAppBrowser.\n *\n * @since 7.12.0\n * @default []\n */\n authorizedAppLinks?: string[];\n}\n\nexport interface InAppBrowserPlugin {\n /**\n * Open url in a new window fullscreen, on android it use chrome custom tabs, on ios it use SFSafariViewController\n *\n * @since 0.1.0\n */\n open(options: OpenOptions): Promise<any>;\n\n /**\n * Clear cookies of url\n *\n * @since 0.5.0\n */\n clearCookies(options: ClearCookieOptions): Promise<any>;\n /**\n * Clear all cookies\n *\n * @since 6.5.0\n */\n clearAllCookies(): Promise<any>;\n\n /**\n * Clear cache\n *\n * @since 6.5.0\n */\n clearCache(): Promise<any>;\n\n /**\n * Get cookies for a specific URL.\n * @param options The options, including the URL to get cookies for.\n * @returns A promise that resolves with the cookies.\n */\n getCookies(options: GetCookieOptions): Promise<Record<string, string>>;\n /**\n * Close the webview.\n */\n close(): Promise<any>;\n /**\n * Open url in a new webview with toolbars, and enhanced capabilities, like camera access, file access, listen events, inject javascript, bi directional communication, etc.\n *\n * JavaScript Interface:\n * When you open a webview with this method, a JavaScript interface is automatically injected that provides:\n * - `window.mobileApp.close()`: Closes the webview from JavaScript\n * - `window.mobileApp.postMessage({detail: {message: 'myMessage'}})`: Sends a message from the webview to the app, detail object is the data you want to send to the webview\n *\n * @since 0.1.0\n */\n openWebView(options: OpenWebViewOptions): Promise<any>;\n /**\n * Injects JavaScript code into the InAppBrowser window.\n */\n executeScript({ code }: { code: string }): Promise<void>;\n /**\n * Sends an event to the webview(inappbrowser). you can listen to this event in the inappbrowser JS with window.addEventListener(\"messageFromNative\", listenerFunc: (event: Record<string, any>) => void)\n * detail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects\n * Your object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.\n */\n postMessage(options: { detail: Record<string, any> }): Promise<void>;\n /**\n * Sets the URL of the webview.\n */\n setUrl(options: { url: string }): Promise<any>;\n /**\n * Listen for url change, only for openWebView\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"urlChangeEvent\",\n listenerFunc: UrlChangeListener,\n ): Promise<PluginListenerHandle>;\n\n addListener(\n eventName: \"buttonNearDoneClick\",\n listenerFunc: ButtonNearListener,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for close click only for openWebView\n *\n * @since 0.4.0\n */\n addListener(\n eventName: \"closeEvent\",\n listenerFunc: UrlChangeListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Will be triggered when user clicks on confirm button when disclaimer is required\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"confirmBtnClicked\",\n listenerFunc: ConfirmBtnListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Will be triggered when event is sent from webview(inappbrowser), to send an event to the main app use window.mobileApp.postMessage({ \"detail\": { \"message\": \"myMessage\" } })\n * detail is the data you want to send to the main app, it's a requirement of Capacitor we cannot send direct objects\n * Your object has to be serializable to JSON, no functions or other non-JSON-serializable types are allowed.\n *\n * This method is inject at runtime in the webview\n */\n addListener(\n eventName: \"messageFromWebview\",\n listenerFunc: (event: { detail: Record<string, any> }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Will be triggered when page is loaded\n */\n addListener(\n eventName: \"browserPageLoaded\",\n listenerFunc: () => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Will be triggered when page load error\n */\n addListener(\n eventName: \"pageLoadError\",\n listenerFunc: () => void,\n ): Promise<PluginListenerHandle>;\n /**\n * Remove all listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Reload the current web page.\n *\n * @since 1.0.0\n */\n reload(): Promise<any>;\n}\n\n/**\n * JavaScript APIs available in the InAppBrowser WebView.\n *\n * These APIs are automatically injected into all webpages loaded in the InAppBrowser WebView.\n *\n * @example\n * // Closing the webview from JavaScript\n * window.mobileApp.close();\n *\n * // Sending a message from webview to the native app\n * window.mobileApp.postMessage({ key: 'value' });\n *\n * @since 6.10.0\n */\nexport interface InAppBrowserWebViewAPIs {\n /**\n * mobileApp - Global object injected into the WebView providing communication with the native app\n */\n mobileApp: {\n /**\n * Close the WebView from JavaScript\n *\n * @example\n * // Add a button to close the webview\n * const closeButton = document.createElement('button');\n * closeButton.textContent = 'Close WebView';\n * closeButton.addEventListener('click', () => {\n * window.mobileApp.close();\n * });\n * document.body.appendChild(closeButton);\n *\n * @since 6.10.0\n */\n close(): void;\n\n /**\n * Send a message from the WebView to the native app\n * The native app can listen for these messages with the \"messageFromWebview\" event\n *\n * @param message Object to send to the native app\n * @example\n * // Send data to native app\n * window.mobileApp.postMessage({\n * action: 'dataSubmitted',\n * data: { username: 'test', email: 'test@example.com' }\n * });\n *\n * @since 6.10.0\n */\n postMessage(message: Record<string, any>): void;\n };\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAuBA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AACD,MAAM,CAAN,IAAY,WAqBX;AArBD,WAAY,WAAW;IACrB;;;OAGG;IACH,oCAAqB,CAAA;IACrB;;;OAGG;IACH,kCAAmB,CAAA;IACnB;;;OAGG;IACH,wCAAyB,CAAA;IACzB;;;OAGG;IACH,8BAAe,CAAA;AACjB,CAAC,EArBW,WAAW,KAAX,WAAW,QAqBtB","sourcesContent":["import type { PluginListenerHandle } from \"@capacitor/core\";\n\nexport interface UrlEvent {\n /**\n * Emit when the url changes\n *\n * @since 0.0.1\n */\n url: string;\n}\nexport interface BtnEvent {\n /**\n * Emit when a button is clicked.\n *\n * @since 0.0.1\n */\n url: string;\n}\n\nexport type UrlChangeListener = (state: UrlEvent) => void;\nexport type ConfirmBtnListener = (state: BtnEvent) => void;\nexport type ButtonNearListener = (state: object) => void;\n\nexport enum BackgroundColor {\n WHITE = \"white\",\n BLACK = \"black\",\n}\nexport enum ToolBarType {\n /**\n * Shows a simple toolbar with just a close button and share button\n * @since 0.1.0\n */\n ACTIVITY = \"activity\",\n /**\n * Shows a simple toolbar with just a close button\n * @since 7.6.8\n */\n COMPACT = \"compact\",\n /**\n * Shows a full navigation toolbar with back/forward buttons\n * @since 0.1.0\n */\n NAVIGATION = \"navigation\",\n /**\n * Shows no toolbar\n * @since 0.1.0\n */\n BLANK = \"blank\",\n}\n\nexport interface Headers {\n [key: string]: string;\n}\n\nexport interface GetCookieOptions {\n url: string;\n includeHttpOnly?: boolean;\n}\n\nexport interface ClearCookieOptions {\n url: string;\n}\n\nexport interface Credentials {\n username: string;\n password: string;\n}\n\nexport interface OpenOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n */\n url: string;\n /**\n * if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n */\n isPresentAfterPageLoad?: boolean;\n /**\n * if true the deeplink will not be opened, if false the deeplink will be opened when clicked on the link\n * @since 0.1.0\n */\n preventDeeplink?: boolean;\n}\n\nexport interface DisclaimerOptions {\n /**\n * Title of the disclaimer dialog\n * @default \"Title\"\n */\n title: string;\n /**\n * Message shown in the disclaimer dialog\n * @default \"Message\"\n */\n message: string;\n /**\n * Text for the confirm button\n * @default \"Confirm\"\n */\n confirmBtn: string;\n /**\n * Text for the cancel button\n * @default \"Cancel\"\n */\n cancelBtn: string;\n}\n\nexport interface OpenWebViewOptions {\n /**\n * Target URL to load.\n * @since 0.1.0\n * @example \"https://capgo.app\"\n */\n url: string;\n /**\n * Headers to send with the request.\n * @since 0.1.0\n * @example\n * headers: {\n * 'Custom-Header': 'test-value',\n * 'Authorization': 'Bearer test-token'\n * }\n * Test URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/\n */\n headers?: Headers;\n /**\n * Credentials to send with the request and all subsequent requests for the same host.\n * @since 6.1.0\n * @example\n * credentials: {\n * username: 'test-user',\n * password: 'test-pass'\n * }\n * Test URL: https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending/\n */\n credentials?: Credentials;\n /**\n * materialPicker: if true, uses Material Design theme for date and time pickers on Android.\n * This improves the appearance of HTML date inputs to use modern Material Design UI instead of the old style pickers.\n * @since 7.4.1\n * @default false\n * @example\n * materialPicker: true\n * Test URL: https://show-picker.glitch.me/demo.html\n */\n materialPicker?: boolean;\n /**\n * JavaScript Interface:\n * The webview automatically injects a JavaScript interface providing:\n * - `window.mobileApp.close()`: Closes the webview from JavaScript\n * - `window.mobileApp.postMessage(obj)`: Sends a message to the app (listen via \"messageFromWebview\" event)\n *\n * @example\n * // In your webpage loaded in the webview:\n * document.getElementById('closeBtn').addEventListener('click', () => {\n * window.mobileApp.close();\n * });\n *\n * // Send data to the app\n * window.mobileApp.postMessage({ action: 'login', data: { user: 'test' }});\n *\n * @since 6.10.0\n */\n jsInterface?: never; // This property doesn't exist, it's just for documentation\n /**\n * Share options for the webview. When provided, shows a disclaimer dialog before sharing content.\n * This is useful for:\n * - Warning users about sharing sensitive information\n * - Getting user consent before sharing\n * - Explaining what will be shared\n * - Complying with privacy regulations\n *\n * Note: shareSubject is required when using shareDisclaimer\n * @since 0.1.0\n * @example\n * shareDisclaimer: {\n * title: 'Disclaimer',\n * message: 'This is a test disclaimer',\n * confirmBtn: 'Accept',\n * cancelBtn: 'Decline'\n * }\n * Test URL: https://capgo.app\n */\n shareDisclaimer?: DisclaimerOptions;\n /**\n * Toolbar type determines the appearance and behavior of the browser's toolbar\n * - \"activity\": Shows a simple toolbar with just a close button and share button\n * - \"navigation\": Shows a full navigation toolbar with back/forward buttons\n * - \"blank\": Shows no toolbar\n * - \"\": Default toolbar with close button\n * @since 0.1.0\n * @default ToolBarType.DEFAULT\n * @example\n * toolbarType: ToolBarType.ACTIVITY,\n * title: 'Activity Toolbar Test'\n * Test URL: https://capgo.app\n */\n toolbarType?: ToolBarType;\n /**\n * Subject text for sharing. Required when using shareDisclaimer.\n * This text will be used as the subject line when sharing content.\n * @since 0.1.0\n * @example \"Share this page\"\n */\n shareSubject?: string;\n /**\n * Title of the browser\n * @since 0.1.0\n * @default 'New Window'\n * @example \"Camera Test\"\n */\n title?: string;\n /**\n * Background color of the browser\n * @since 0.1.0\n * @default BackgroundColor.BLACK\n */\n backgroundColor?: BackgroundColor;\n /**\n * If true, active the native navigation within the webview, Android only\n * @default false\n * @example\n * activeNativeNavigationForWebview: true,\n * disableGoBackOnNativeApplication: true\n * Test URL: https://capgo.app\n */\n activeNativeNavigationForWebview?: boolean;\n /**\n * Disable the possibility to go back on native application,\n * useful to force user to stay on the webview, Android only\n * @default false\n * @example\n * disableGoBackOnNativeApplication: true\n * Test URL: https://capgo.app\n */\n disableGoBackOnNativeApplication?: boolean;\n /**\n * Open url in a new window fullscreen\n * isPresentAfterPageLoad: if true, the browser will be presented after the page is loaded, if false, the browser will be presented immediately.\n * @since 0.1.0\n * @default false\n * @example\n * isPresentAfterPageLoad: true,\n * preShowScript: \"await import('https://unpkg.com/darkreader@4.9.89/darkreader.js');\\nDarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 });\"\n * Test URL: https://capgo.app\n */\n isPresentAfterPageLoad?: boolean;\n /**\n * Whether the website in the webview is inspectable or not, ios only\n * @default false\n */\n isInspectable?: boolean;\n /**\n * Whether the webview opening is animated or not, ios only\n * @default true\n */\n isAnimated?: boolean;\n /**\n * Shows a reload button that reloads the web page\n * @since 1.0.15\n * @default false\n * @example\n * showReloadButton: true\n * Test URL: https://capgo.app\n */\n showReloadButton?: boolean;\n /**\n * CloseModal: if true a confirm will be displayed when user clicks on close button, if false the browser will be closed immediately.\n * @since 1.1.0\n * @default false\n * @example\n * closeModal: true,\n * closeModalTitle: 'Close Window',\n * closeModalDescription: 'Are you sure you want to close?',\n * closeModalOk: 'Yes, close',\n * closeModalCancel: 'No, stay'\n * Test URL: https://capgo.app\n */\n closeModal?: boolean;\n /**\n * CloseModalTitle: title of the confirm when user clicks on close button\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalTitle?: string;\n /**\n * CloseModalDescription: description of the confirm when user clicks on close button\n * @since 1.1.0\n * @default 'Are you sure you want to close this window?'\n */\n closeModalDescription?: string;\n /**\n * CloseModalOk: text of the confirm button when user clicks on close button\n * @since 1.1.0\n * @default 'Close'\n */\n closeModalOk?: string;\n /**\n * CloseModalCancel: text of the cancel button when user clicks on close button\n * @since 1.1.0\n * @default 'Cancel'\n */\n closeModalCancel?: string;\n /**\n * visibleTitle: if true the website title would be shown else shown empty\n * @since 1.2.5\n * @default true\n */\n visibleTitle?: boolean;\n /**\n * toolbarColor: color of the toolbar in hex format\n * @since 1.2.5\n * @default '#ffffff'\n * @example\n * toolbarColor: '#FF5733'\n * Test URL: https://capgo.app\n */\n toolbarColor?: string;\n /**\n * toolbarTextColor: color of the buttons and title in the toolbar in hex format\n * When set, it overrides the automatic light/dark mode detection for text color\n * @since 6.10.0\n * @default calculated based on toolbarColor brightness\n * @example\n * toolbarTextColor: '#FFFFFF'\n * Test URL: https://capgo.app\n */\n toolbarTextColor?: string;\n /**\n * showArrow: if true an arrow would be shown instead of cross for closing the window\n * @since 1.2.5\n * @default false\n * @example\n * showArrow: true\n * Test URL: https://capgo.app\n */\n showArrow?: boolean;\n /**\n * ignoreUntrustedSSLError: if true, the webview will ignore untrusted SSL errors allowing the user to view the website.\n * @since 6.1.0\n * @default false\n */\n ignoreUntrustedSSLError?: boolean;\n /**\n * preShowScript: if isPresentAfterPageLoad is true and this variable is set the plugin will inject a script before showing the browser.\n * This script will be run in an async context. The plugin will wait for the script to finish (max 10 seconds)\n * @since 6.6.0\n * @example\n * preShowScript: \"await import('https://unpkg.com/darkreader@4.9.89/darkreader.js');\\nDarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 });\"\n * Test URL: https://capgo.app\n */\n preShowScript?: string;\n /**\n * proxyRequests is a regex expression. Please see [this pr](https://github.com/Cap-go/capacitor-inappbrowser/pull/222) for more info. (Android only)\n * @since 6.9.0\n */\n proxyRequests?: string;\n /**\n * buttonNearDone allows for a creation of a custom button near the done/close button.\n * The button is only shown when toolbarType is not \"activity\", \"navigation\", or \"blank\".\n *\n * For Android:\n * - iconType must be \"asset\"\n * - icon path should be in the public folder (e.g. \"monkey.svg\")\n * - width and height are optional, defaults to 48dp\n * - button is positioned at the end of toolbar with 8dp margin\n *\n * For iOS:\n * - iconType can be \"sf-symbol\" or \"asset\"\n * - for sf-symbol, icon should be the symbol name\n * - for asset, icon should be the asset name\n * @since 6.7.0\n * @example\n * buttonNearDone: {\n * ios: {\n * iconType: 'sf-symbol',\n * icon: 'star.fill'\n * },\n * android: {\n * iconType: 'asset',\n * icon: 'public/monkey.svg',\n * width: 24,\n * height: 24\n * }\n * }\n * Test URL: https://capgo.app\n */\n buttonNearDone?: {\n ios: {\n iconType: \"sf-symbol\" | \"asset\";\n icon: string;\n };\n android: {\n iconType: \"asset\" | \"vector\";\n icon: string;\n width?: number;\n height?: number;\n };\n };\n /**\n * textZoom: sets the text zoom of the page in percent.\n * Allows users to increase or decrease the text size for better readability.\n * @since 7.6.0\n * @default 100\n * @example\n * textZoom: 120\n * Test URL: https://capgo.app\n */\n textZoom?: number;\n /**\n * preventDeeplink: if true, the deeplink will not be opened, if false the deeplink will be opened when clicked on the link. on IOS each schema need to be added to info.plist file under LSApplicationQueriesSchemes when false to make it work.\n * @since 0.1.0\n * @default false\n * @example\n * preventDeeplink: true\n * Test URL: https://aasa-tester.capgo.app/\n */\n preventDeeplink?: boolean;\n\n /**\n * List of URL base patterns that should be treated as authorized App Links, Android only.\n * Only links starting with any of these base URLs will be opened in the InAppBrowser.\n *\n * @since 7.12.0\n * @default []\n */\n authorizedAppLinks?: string[];\n\n /**\n * enableGooglePaySupport: if true, enables support for Google Pay popups and Payment Request API.\n * This fixes OR_BIBED_15 errors by allowing popup windows and configuring Cross-Origin-Opener-Policy.\n * Only enable this if you need Google Pay functionality as it allows popup windows.\n *\n * When enabled:\n * - Allows popup windows for Google Pay authentication\n * - Sets proper CORS headers for Payment Request API\n * - Enables multiple window support in WebView\n * - Configures secure context for payment processing\n *\n * @since 7.13.0\n * @default false\n * @example\n * enableGooglePaySupport: true\n * Test URL: https://developers.google.com/pay/api/web/guides/tutorial\n */\n enableGooglePaySupport?: boolean;\n}\n\nexport interface InAppBrowserPlugin {\n /**\n * Open url in a new window fullscreen, on android it use chrome custom tabs, on ios it use SFSafariViewController\n *\n * @since 0.1.0\n */\n open(options: OpenOptions): Promise<any>;\n\n /**\n * Clear cookies of url\n *\n * @since 0.5.0\n */\n clearCookies(options: ClearCookieOptions): Promise<any>;\n /**\n * Clear all cookies\n *\n * @since 6.5.0\n */\n clearAllCookies(): Promise<any>;\n\n /**\n * Clear cache\n *\n * @since 6.5.0\n */\n clearCache(): Promise<any>;\n\n /**\n * Get cookies for a specific URL.\n * @param options The options, including the URL to get cookies for.\n * @returns A promise that resolves with the cookies.\n */\n getCookies(options: GetCookieOptions): Promise<Record<string, string>>;\n /**\n * Close the webview.\n */\n close(): Promise<any>;\n /**\n * Open url in a new webview with toolbars, and enhanced capabilities, like camera access, file access, listen events, inject javascript, bi directional communication, etc.\n *\n * JavaScript Interface:\n * When you open a webview with this method, a JavaScript interface is automatically injected that provides:\n * - `window.mobileApp.close()`: Closes the webview from JavaScript\n * - `window.mobileApp.postMessage({detail: {message: 'myMessage'}})`: Sends a message from the webview to the app, detail object is the data you want to send to the webview\n *\n * @since 0.1.0\n */\n openWebView(options: OpenWebViewOptions): Promise<any>;\n /**\n * Injects JavaScript code into the InAppBrowser window.\n */\n executeScript({ code }: { code: string }): Promise<void>;\n /**\n * Sends an event to the webview(inappbrowser). you can listen to this event in the inappbrowser JS with window.addEventListener(\"messageFromNative\", listenerFunc: (event: Record<string, any>) => void)\n * detail is the data you want to send to the webview, it's a requirement of Capacitor we cannot send direct objects\n * Your object has to be serializable to JSON, so no functions or other non-JSON-serializable types are allowed.\n */\n postMessage(options: { detail: Record<string, any> }): Promise<void>;\n /**\n * Sets the URL of the webview.\n */\n setUrl(options: { url: string }): Promise<any>;\n /**\n * Listen for url change, only for openWebView\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"urlChangeEvent\",\n listenerFunc: UrlChangeListener,\n ): Promise<PluginListenerHandle>;\n\n addListener(\n eventName: \"buttonNearDoneClick\",\n listenerFunc: ButtonNearListener,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Listen for close click only for openWebView\n *\n * @since 0.4.0\n */\n addListener(\n eventName: \"closeEvent\",\n listenerFunc: UrlChangeListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Will be triggered when user clicks on confirm button when disclaimer is required\n *\n * @since 0.0.1\n */\n addListener(\n eventName: \"confirmBtnClicked\",\n listenerFunc: ConfirmBtnListener,\n ): Promise<PluginListenerHandle>;\n /**\n * Will be triggered when event is sent from webview(inappbrowser), to send an event to the main app use window.mobileApp.postMessage({ \"detail\": { \"message\": \"myMessage\" } })\n * detail is the data you want to send to the main app, it's a requirement of Capacitor we cannot send direct objects\n * Your object has to be serializable to JSON, no functions or other non-JSON-serializable types are allowed.\n *\n * This method is inject at runtime in the webview\n */\n addListener(\n eventName: \"messageFromWebview\",\n listenerFunc: (event: { detail: Record<string, any> }) => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Will be triggered when page is loaded\n */\n addListener(\n eventName: \"browserPageLoaded\",\n listenerFunc: () => void,\n ): Promise<PluginListenerHandle>;\n\n /**\n * Will be triggered when page load error\n */\n addListener(\n eventName: \"pageLoadError\",\n listenerFunc: () => void,\n ): Promise<PluginListenerHandle>;\n /**\n * Remove all listeners for this plugin.\n *\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>;\n\n /**\n * Reload the current web page.\n *\n * @since 1.0.0\n */\n reload(): Promise<any>;\n}\n\n/**\n * JavaScript APIs available in the InAppBrowser WebView.\n *\n * These APIs are automatically injected into all webpages loaded in the InAppBrowser WebView.\n *\n * @example\n * // Closing the webview from JavaScript\n * window.mobileApp.close();\n *\n * // Sending a message from webview to the native app\n * window.mobileApp.postMessage({ key: 'value' });\n *\n * @since 6.10.0\n */\nexport interface InAppBrowserWebViewAPIs {\n /**\n * mobileApp - Global object injected into the WebView providing communication with the native app\n */\n mobileApp: {\n /**\n * Close the WebView from JavaScript\n *\n * @example\n * // Add a button to close the webview\n * const closeButton = document.createElement('button');\n * closeButton.textContent = 'Close WebView';\n * closeButton.addEventListener('click', () => {\n * window.mobileApp.close();\n * });\n * document.body.appendChild(closeButton);\n *\n * @since 6.10.0\n */\n close(): void;\n\n /**\n * Send a message from the WebView to the native app\n * The native app can listen for these messages with the \"messageFromWebview\" event\n *\n * @param message Object to send to the native app\n * @example\n * // Send data to native app\n * window.mobileApp.postMessage({\n * action: 'dataSubmitted',\n * data: { username: 'test', email: 'test@example.com' }\n * });\n *\n * @since 6.10.0\n */\n postMessage(message: Record<string, any>): void;\n };\n}\n"]}
@@ -349,6 +349,7 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
349
349
  // }
350
350
 
351
351
  let ignoreUntrustedSSLError = call.getBool("ignoreUntrustedSSLError", false)
352
+ let enableGooglePaySupport = call.getBool("enableGooglePaySupport", false)
352
353
 
353
354
  self.isPresentAfterPageLoad = call.getBool("isPresentAfterPageLoad", false)
354
355
  let showReloadButton = call.getBool("showReloadButton", false)
@@ -470,6 +471,9 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
470
471
  webViewController.websiteTitleInNavigationBar = call.getBool("visibleTitle", true)
471
472
  webViewController.ignoreUntrustedSSLError = ignoreUntrustedSSLError
472
473
 
474
+ // Set Google Pay support
475
+ webViewController.enableGooglePaySupport = enableGooglePaySupport
476
+
473
477
  // Set text zoom if specified
474
478
  if let textZoom = call.getInt("textZoom") {
475
479
  webViewController.textZoom = textZoom
@@ -109,6 +109,7 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
109
109
  open var closeModalOk = ""
110
110
  open var closeModalCancel = ""
111
111
  open var ignoreUntrustedSSLError = false
112
+ open var enableGooglePaySupport = false
112
113
  var viewWasPresented = false
113
114
  var preventDeeplink: Bool = false
114
115
  var blankNavigationTab: Bool = false
@@ -448,12 +449,12 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
448
449
  print("[InAppBrowser] Failed to serialize message to JSON")
449
450
  return
450
451
  }
451
-
452
+
452
453
  // Safely build the script to avoid any potential issues
453
454
  let script = "window.dispatchEvent(new CustomEvent('messageFromNative', { detail: \(jsonString) }));"
454
-
455
+
455
456
  DispatchQueue.main.async {
456
- self.webView?.evaluateJavaScript(script) { result, error in
457
+ self.webView?.evaluateJavaScript(script) { _, error in
457
458
  if let error = error {
458
459
  print("[InAppBrowser] JavaScript evaluation error in postMessageToJS: \(error)")
459
460
  }
@@ -562,6 +563,56 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
562
563
  webConfiguration.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs")
563
564
  webConfiguration.setValue(true, forKey: "allowUniversalAccessFromFileURLs")
564
565
 
566
+ // Enhanced configuration for Google Pay support (only when enabled)
567
+ if enableGooglePaySupport {
568
+ print("[InAppBrowser] Enabling Google Pay support features for iOS")
569
+
570
+ // Allow arbitrary loads in web views for Payment Request API
571
+ webConfiguration.setValue(true, forKey: "allowsArbitraryLoads")
572
+
573
+ // Enable JavaScript popup support for Google Pay
574
+ webConfiguration.preferences.javaScriptCanOpenWindowsAutomatically = true
575
+
576
+ // Inject Google Pay support script
577
+ let googlePayScript = WKUserScript(
578
+ source: """
579
+ console.log('[InAppBrowser] Injecting Google Pay support for iOS');
580
+
581
+ // Enhanced window.open for Google Pay
582
+ (function() {
583
+ const originalWindowOpen = window.open;
584
+ window.open = function(url, target, features) {
585
+ console.log('[InAppBrowser iOS] Enhanced window.open called:', url, target, features);
586
+
587
+ // For Google Pay URLs, handle popup properly
588
+ if (url && (url.includes('google.com/pay') || url.includes('accounts.google.com'))) {
589
+ console.log('[InAppBrowser iOS] Google Pay popup detected');
590
+ return originalWindowOpen.call(window, url, target || '_blank', features);
591
+ }
592
+
593
+ return originalWindowOpen.call(window, url, target, features);
594
+ };
595
+
596
+ // Add Cross-Origin-Opener-Policy meta tag if not present
597
+ if (!document.querySelector('meta[http-equiv="Cross-Origin-Opener-Policy"]')) {
598
+ const meta = document.createElement('meta');
599
+ meta.setAttribute('http-equiv', 'Cross-Origin-Opener-Policy');
600
+ meta.setAttribute('content', 'same-origin-allow-popups');
601
+ if (document.head) {
602
+ document.head.appendChild(meta);
603
+ console.log('[InAppBrowser iOS] Added Cross-Origin-Opener-Policy meta tag');
604
+ }
605
+ }
606
+
607
+ console.log('[InAppBrowser iOS] Google Pay support enhancements complete');
608
+ })();
609
+ """,
610
+ injectionTime: .atDocumentStart,
611
+ forMainFrameOnly: false
612
+ )
613
+ userContentController.addUserScript(googlePayScript)
614
+ }
615
+
565
616
  let webView = WKWebView(frame: .zero, configuration: webConfiguration)
566
617
 
567
618
  // if webView.responds(to: Selector(("setInspectable:"))) {
@@ -1350,7 +1401,7 @@ extension WKWebViewController: WKNavigationDelegate {
1350
1401
 
1351
1402
  // Safely construct script template with proper escaping
1352
1403
  let userScript = self.preShowScript ?? ""
1353
-
1404
+
1354
1405
  // Build script using safe concatenation to avoid multi-line string issues
1355
1406
  let scriptTemplate = [
1356
1407
  "async function preShowFunction() {",
@@ -1365,7 +1416,7 @@ extension WKWebViewController: WKNavigationDelegate {
1365
1416
  " }",
1366
1417
  ")"
1367
1418
  ]
1368
-
1419
+
1369
1420
  let script = scriptTemplate.joined(separator: "\n")
1370
1421
  print("[InAppBrowser - InjectPreShowScript] PreShowScript script: \(script)")
1371
1422
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "7.12.1",
3
+ "version": "7.13.0",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",