@capgo/inappbrowser 7.12.1 → 7.14.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
@@ -22,6 +22,31 @@ import { InAppBrowser } from '@capgo/inappbrowser'
22
22
  InAppBrowser.open({ url: "YOUR_URL" });
23
23
  ```
24
24
 
25
+ ### Open WebView with Safe Margin
26
+
27
+ To create a webView with a 20px bottom margin (safe margin area outside the browser):
28
+
29
+ ```js
30
+ import { InAppBrowser } from '@capgo/inappbrowser'
31
+
32
+ InAppBrowser.openWebView({
33
+ url: "YOUR_URL",
34
+ enabledSafeMargin: true
35
+ });
36
+ ```
37
+
38
+ To create a webView with a custom safe margin:
39
+
40
+ ```js
41
+ import { InAppBrowser } from '@capgo/inappbrowser'
42
+
43
+ InAppBrowser.openWebView({
44
+ url: "YOUR_URL",
45
+ enabledSafeMargin: true,
46
+ safeMargin: 30 // Custom 30px margin
47
+ });
48
+ ```
49
+
25
50
  Web platform is not supported. Use `window.open` instead.
26
51
 
27
52
 
@@ -551,6 +576,9 @@ Reload the current web page.
551
576
  | **`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
577
  | **`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
578
  | **`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 |
579
+ | **`enabledSafeMargin`** | <code>boolean</code> | If true, the webView will not take the full height and will have a 20px margin at the bottom. This creates a safe margin area outside the browser view. | <code>false</code> | 7.13.0 |
580
+ | **`safeMargin`** | <code>number</code> | Custom safe margin value in pixels. Only used when enabledSafeMargin is true. If not specified, defaults to 20px. | <code>20</code> | 7.13.0 |
581
+ | **`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
582
 
555
583
 
556
584
  #### Headers
@@ -59,6 +59,5 @@ dependencies {
59
59
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
60
60
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
61
61
  implementation "androidx.browser:browser:$androidxBrowserVersion"
62
- implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
63
62
  implementation 'com.google.android.material:material:1.12.0'
64
63
  }
@@ -654,6 +654,55 @@ public class InAppBrowserPlugin
654
654
  Boolean.TRUE.equals(call.getBoolean("materialPicker", false))
655
655
  );
656
656
 
657
+ // Set enabledSafeMargin option
658
+ options.setEnabledSafeMargin(
659
+ Boolean.TRUE.equals(call.getBoolean("enabledSafeMargin", false))
660
+ );
661
+
662
+ // Set safeMargin option with proper handling
663
+ try {
664
+ // Try multiple ways to get the safeMargin value
665
+ Integer safeMarginValue = null;
666
+
667
+ // First try as integer
668
+ if (call.hasOption("safeMargin")) {
669
+ safeMarginValue = call.getInt("safeMargin");
670
+ Log.d("InAppBrowser", "safeMargin from getInt(): " + safeMarginValue);
671
+ }
672
+
673
+ // If that didn't work, try as double and convert to int
674
+ if (safeMarginValue == null && call.hasOption("safeMargin")) {
675
+ Double safeMarginDouble = call.getDouble("safeMargin");
676
+ if (safeMarginDouble != null) {
677
+ safeMarginValue = safeMarginDouble.intValue();
678
+ Log.d(
679
+ "InAppBrowser",
680
+ "safeMargin from getDouble(): " +
681
+ safeMarginDouble +
682
+ " -> " +
683
+ safeMarginValue
684
+ );
685
+ }
686
+ }
687
+
688
+ if (safeMarginValue != null && safeMarginValue > 0) {
689
+ options.setSafeMargin(safeMarginValue);
690
+ Log.d("InAppBrowser", "Custom safeMargin set to: " + safeMarginValue);
691
+ } else {
692
+ // Keep default value (20) from Options class
693
+ Log.d(
694
+ "InAppBrowser",
695
+ "Using default safeMargin: " + options.getSafeMargin()
696
+ );
697
+ }
698
+ } catch (Exception e) {
699
+ Log.e("InAppBrowser", "Error setting safeMargin: " + e.getMessage());
700
+ Log.d(
701
+ "InAppBrowser",
702
+ "Using default safeMargin: " + options.getSafeMargin()
703
+ );
704
+ }
705
+
657
706
  // options.getToolbarItemTypes().add(ToolbarItemType.RELOAD); TODO: fix this
658
707
  options.setCallbacks(
659
708
  new WebViewCallbacks() {
@@ -752,6 +801,11 @@ public class InAppBrowserPlugin
752
801
  Log.d("InAppBrowserPlugin", "No authorized app links provided.");
753
802
  }
754
803
 
804
+ // Set Google Pay support option
805
+ options.setEnableGooglePaySupport(
806
+ Boolean.TRUE.equals(call.getBoolean("enableGooglePaySupport", false))
807
+ );
808
+
755
809
  this.getActivity()
756
810
  .runOnUiThread(
757
811
  new Runnable() {
@@ -180,6 +180,9 @@ 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 enabledSafeMargin = false;
184
+ private int safeMargin = 20; // Default safe margin in pixels
185
+ private boolean enableGooglePaySupport = false;
183
186
 
184
187
  public int getTextZoom() {
185
188
  return textZoom;
@@ -197,6 +200,22 @@ public class Options {
197
200
  this.materialPicker = materialPicker;
198
201
  }
199
202
 
203
+ public boolean getEnabledSafeMargin() {
204
+ return enabledSafeMargin;
205
+ }
206
+
207
+ public void setEnabledSafeMargin(boolean enabledSafeMargin) {
208
+ this.enabledSafeMargin = enabledSafeMargin;
209
+ }
210
+
211
+ public int getSafeMargin() {
212
+ return safeMargin;
213
+ }
214
+
215
+ public void setSafeMargin(int safeMargin) {
216
+ this.safeMargin = safeMargin;
217
+ }
218
+
200
219
  public Pattern getProxyRequestsPattern() {
201
220
  return proxyRequestsPattern;
202
221
  }
@@ -434,4 +453,12 @@ public class Options {
434
453
  public void setAuthorizedAppLinks(List<String> authorizedAppLinks) {
435
454
  this.authorizedAppLinks = authorizedAppLinks;
436
455
  }
456
+
457
+ public boolean getEnableGooglePaySupport() {
458
+ return enableGooglePaySupport;
459
+ }
460
+
461
+ public void setEnableGooglePaySupport(boolean enableGooglePaySupport) {
462
+ this.enableGooglePaySupport = enableGooglePaySupport;
463
+ }
437
464
  }
@@ -47,6 +47,7 @@ import android.webkit.WebView;
47
47
  import android.webkit.WebViewClient;
48
48
  import android.widget.ImageButton;
49
49
  import android.widget.ImageView;
50
+ import android.widget.RelativeLayout;
50
51
  import android.widget.TextView;
51
52
  import android.widget.Toast;
52
53
  import android.widget.Toolbar;
@@ -374,6 +375,28 @@ public class WebViewDialog extends Dialog {
374
375
 
375
376
  this._webView = findViewById(R.id.browser_view);
376
377
 
378
+ // Apply safe margin if enabled
379
+ if (_options.getEnabledSafeMargin()) {
380
+ WebView webView = findViewById(R.id.browser_view);
381
+
382
+ if (webView != null) {
383
+ // Use custom safe margin value from options (defaults to 20)
384
+ int marginHeightDp = _options.getSafeMargin();
385
+ float density = _context.getResources().getDisplayMetrics().density;
386
+ int marginHeightPx = (int) (marginHeightDp * density);
387
+
388
+ View parentContainer = findViewById(android.R.id.content);
389
+ if (parentContainer != null) {
390
+ parentContainer.setPadding(
391
+ parentContainer.getPaddingLeft(),
392
+ parentContainer.getPaddingTop(),
393
+ parentContainer.getPaddingRight(),
394
+ parentContainer.getPaddingBottom() + marginHeightPx
395
+ );
396
+ }
397
+ }
398
+ }
399
+
377
400
  // Apply insets to fix edge-to-edge issues on Android 15+
378
401
  applyInsets();
379
402
 
@@ -400,6 +423,27 @@ public class WebViewDialog extends Dialog {
400
423
  _webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
401
424
  _webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
402
425
 
426
+ // Enhanced settings for Google Pay and Payment Request API support (only when enabled)
427
+ if (_options.getEnableGooglePaySupport()) {
428
+ Log.d("InAppBrowser", "Enabling Google Pay support features");
429
+ _webView
430
+ .getSettings()
431
+ .setMixedContentMode(
432
+ android.webkit.WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
433
+ );
434
+ _webView.getSettings().setSupportMultipleWindows(true);
435
+ _webView.getSettings().setGeolocationEnabled(true);
436
+
437
+ // Ensure secure context for Payment Request API
438
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
439
+ _webView
440
+ .getSettings()
441
+ .setMixedContentMode(
442
+ android.webkit.WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE
443
+ );
444
+ }
445
+ }
446
+
403
447
  // Set web view background color
404
448
  int backgroundColor = _options.getBackgroundColor().equals("white")
405
449
  ? Color.WHITE
@@ -850,6 +894,88 @@ public class WebViewDialog extends Dialog {
850
894
  injectDatePickerFixes();
851
895
  }
852
896
  }
897
+
898
+ // Support for Google Pay and popup windows (critical for OR_BIBED_15 fix)
899
+ @Override
900
+ public boolean onCreateWindow(
901
+ WebView view,
902
+ boolean isDialog,
903
+ boolean isUserGesture,
904
+ android.os.Message resultMsg
905
+ ) {
906
+ Log.d(
907
+ "InAppBrowser",
908
+ "onCreateWindow called - isUserGesture: " +
909
+ isUserGesture +
910
+ ", GooglePaySupport: " +
911
+ _options.getEnableGooglePaySupport()
912
+ );
913
+
914
+ // Only handle popup windows if Google Pay support is enabled
915
+ if (_options.getEnableGooglePaySupport() && isUserGesture) {
916
+ // Create a new WebView for the popup
917
+ WebView popupWebView = new WebView(activity);
918
+ popupWebView.getSettings().setJavaScriptEnabled(true);
919
+ popupWebView
920
+ .getSettings()
921
+ .setJavaScriptCanOpenWindowsAutomatically(true);
922
+ popupWebView.getSettings().setSupportMultipleWindows(true);
923
+
924
+ // Set WebViewClient to handle URL loading and closing
925
+ popupWebView.setWebViewClient(
926
+ new WebViewClient() {
927
+ @Override
928
+ public boolean shouldOverrideUrlLoading(
929
+ WebView view,
930
+ String url
931
+ ) {
932
+ Log.d("InAppBrowser", "Popup WebView loading URL: " + url);
933
+
934
+ // Handle Google Pay result URLs or close conditions
935
+ if (
936
+ url.contains("google.com/pay") ||
937
+ url.contains("close") ||
938
+ url.contains("cancel")
939
+ ) {
940
+ Log.d(
941
+ "InAppBrowser",
942
+ "Closing popup for Google Pay result"
943
+ );
944
+ // Notify the parent WebView and close popup
945
+ activity.runOnUiThread(() -> {
946
+ try {
947
+ if (popupWebView.getParent() != null) {
948
+ ((ViewGroup) popupWebView.getParent()).removeView(
949
+ popupWebView
950
+ );
951
+ }
952
+ popupWebView.destroy();
953
+ } catch (Exception e) {
954
+ Log.e(
955
+ "InAppBrowser",
956
+ "Error closing popup: " + e.getMessage()
957
+ );
958
+ }
959
+ });
960
+ return true;
961
+ }
962
+ return false;
963
+ }
964
+ }
965
+ );
966
+
967
+ // Set up the popup WebView transport
968
+ WebView.WebViewTransport transport =
969
+ (WebView.WebViewTransport) resultMsg.obj;
970
+ transport.setWebView(popupWebView);
971
+ resultMsg.sendToTarget();
972
+
973
+ Log.d("InAppBrowser", "Created popup window for Google Pay");
974
+ return true;
975
+ }
976
+
977
+ return false;
978
+ }
853
979
  }
854
980
  );
855
981
 
@@ -877,6 +1003,12 @@ public class WebViewDialog extends Dialog {
877
1003
  _webView.post(() -> {
878
1004
  if (_webView != null) {
879
1005
  injectJavaScriptInterface();
1006
+
1007
+ // Inject Google Pay support enhancements if enabled
1008
+ if (_options.getEnableGooglePaySupport()) {
1009
+ injectGooglePayPolyfills();
1010
+ }
1011
+
880
1012
  Log.d(
881
1013
  "InAppBrowser",
882
1014
  "JavaScript interface injected early after URL load"
@@ -1215,6 +1347,113 @@ public class WebViewDialog extends Dialog {
1215
1347
  }
1216
1348
  }
1217
1349
 
1350
+ /**
1351
+ * Injects JavaScript polyfills and enhancements for Google Pay support
1352
+ * Helps resolve OR_BIBED_15 errors by ensuring proper cross-origin handling
1353
+ */
1354
+ private void injectGooglePayPolyfills() {
1355
+ if (_webView == null) {
1356
+ Log.w(
1357
+ "InAppBrowser",
1358
+ "Cannot inject Google Pay polyfills - WebView is null"
1359
+ );
1360
+ return;
1361
+ }
1362
+
1363
+ try {
1364
+ String googlePayScript =
1365
+ """
1366
+ (function() {
1367
+ console.log('[InAppBrowser] Injecting Google Pay support enhancements');
1368
+
1369
+ // Enhance window.open to work better with Google Pay popups
1370
+ const originalWindowOpen = window.open;
1371
+ window.open = function(url, target, features) {
1372
+ console.log('[InAppBrowser] Enhanced window.open called:', url, target, features);
1373
+
1374
+ // For Google Pay URLs, ensure they open in a new context
1375
+ if (url && (url.includes('google.com/pay') || url.includes('accounts.google.com'))) {
1376
+ console.log('[InAppBrowser] Google Pay popup detected, using enhanced handling');
1377
+ // Let the native WebView handle this via onCreateWindow
1378
+ return originalWindowOpen.call(window, url, '_blank', features);
1379
+ }
1380
+
1381
+ return originalWindowOpen.call(window, url, target, features);
1382
+ };
1383
+
1384
+ // Ensure proper Payment Request API context
1385
+ if (window.PaymentRequest) {
1386
+ console.log('[InAppBrowser] Payment Request API available');
1387
+
1388
+ // Wrap PaymentRequest constructor to add better error handling
1389
+ const OriginalPaymentRequest = window.PaymentRequest;
1390
+ window.PaymentRequest = function(methodData, details, options) {
1391
+ console.log('[InAppBrowser] PaymentRequest created with enhanced error handling');
1392
+ const request = new OriginalPaymentRequest(methodData, details, options);
1393
+
1394
+ // Override show method to handle popup blocking issues
1395
+ const originalShow = request.show;
1396
+ request.show = function() {
1397
+ console.log('[InAppBrowser] PaymentRequest.show() called');
1398
+ return originalShow.call(this).catch((error) => {
1399
+ console.error('[InAppBrowser] PaymentRequest error:', error);
1400
+ if (error.name === 'SecurityError' || error.message.includes('popup')) {
1401
+ console.log('[InAppBrowser] Attempting to handle popup blocking issue');
1402
+ }
1403
+ throw error;
1404
+ });
1405
+ };
1406
+
1407
+ return request;
1408
+ };
1409
+
1410
+ // Copy static methods
1411
+ Object.setPrototypeOf(window.PaymentRequest, OriginalPaymentRequest);
1412
+ Object.defineProperty(window.PaymentRequest, 'prototype', {
1413
+ value: OriginalPaymentRequest.prototype
1414
+ });
1415
+ }
1416
+
1417
+ // Add meta tag to ensure proper cross-origin handling if not present
1418
+ if (!document.querySelector('meta[http-equiv="Cross-Origin-Opener-Policy"]')) {
1419
+ const meta = document.createElement('meta');
1420
+ meta.setAttribute('http-equiv', 'Cross-Origin-Opener-Policy');
1421
+ meta.setAttribute('content', 'same-origin-allow-popups');
1422
+ if (document.head) {
1423
+ document.head.appendChild(meta);
1424
+ console.log('[InAppBrowser] Added Cross-Origin-Opener-Policy meta tag');
1425
+ }
1426
+ }
1427
+
1428
+ console.log('[InAppBrowser] Google Pay support enhancements complete');
1429
+ })();
1430
+ """;
1431
+
1432
+ _webView.post(() -> {
1433
+ if (_webView != null) {
1434
+ try {
1435
+ _webView.evaluateJavascript(googlePayScript, result -> {
1436
+ Log.d(
1437
+ "InAppBrowser",
1438
+ "Google Pay polyfills injected successfully"
1439
+ );
1440
+ });
1441
+ } catch (Exception e) {
1442
+ Log.e(
1443
+ "InAppBrowser",
1444
+ "Error injecting Google Pay polyfills: " + e.getMessage()
1445
+ );
1446
+ }
1447
+ }
1448
+ });
1449
+ } catch (Exception e) {
1450
+ Log.e(
1451
+ "InAppBrowser",
1452
+ "Error preparing Google Pay polyfills: " + e.getMessage()
1453
+ );
1454
+ }
1455
+ }
1456
+
1218
1457
  private void injectPreShowScript() {
1219
1458
  // String script =
1220
1459
  // "import('https://unpkg.com/darkreader@4.9.89/darkreader.js').then(() => {DarkReader.enable({ brightness: 100, contrast: 90, sepia: 10 });window.PreLoadScriptInterface.finished()})";
@@ -2580,6 +2819,11 @@ public class WebViewDialog extends Dialog {
2580
2819
  }
2581
2820
  super.doUpdateVisitedHistory(view, url, isReload);
2582
2821
  injectJavaScriptInterface();
2822
+
2823
+ // Inject Google Pay polyfills if enabled
2824
+ if (_options.getEnableGooglePaySupport()) {
2825
+ injectGooglePayPolyfills();
2826
+ }
2583
2827
  }
2584
2828
 
2585
2829
  @Override
@@ -2696,6 +2940,11 @@ public class WebViewDialog extends Dialog {
2696
2940
 
2697
2941
  _options.getCallbacks().pageLoaded();
2698
2942
  injectJavaScriptInterface();
2943
+
2944
+ // Inject Google Pay polyfills if enabled
2945
+ if (_options.getEnableGooglePaySupport()) {
2946
+ injectGooglePayPolyfills();
2947
+ }
2699
2948
  }
2700
2949
 
2701
2950
  @Override
@@ -3083,8 +3332,8 @@ public class WebViewDialog extends Dialog {
3083
3332
  Environment.DIRECTORY_PICTURES
3084
3333
  );
3085
3334
  File image = File.createTempFile(
3086
- imageFileName,/* prefix */
3087
- ".jpg",/* suffix */
3335
+ imageFileName/* prefix */,
3336
+ ".jpg"/* suffix */,
3088
3337
  storageDir/* directory */
3089
3338
  );
3090
3339
  return image;
@@ -1,16 +1,28 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
- xmlns:app="http://schemas.android.com/apk/res-auto"
2
+ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
4
3
  xmlns:tools="http://schemas.android.com/tools"
5
4
  android:layout_width="match_parent"
6
5
  android:layout_height="match_parent"
7
- app:layout_behavior="@string/appbar_scrolling_view_behavior"
8
6
  tools:context="com.cap.browser.plugin.WebViewActivity"
9
7
  tools:showIn="@layout/activity_browser">
10
8
 
11
9
  <WebView
12
10
  android:id="@+id/browser_view"
13
11
  android:layout_width="match_parent"
14
- android:layout_height="match_parent"/>
12
+ android:layout_height="match_parent"
13
+ android:layout_alignParentTop="true"
14
+ android:layout_alignParentLeft="true"
15
+ android:layout_alignParentRight="true"
16
+ android:layout_alignParentBottom="true" />
15
17
 
16
- </androidx.constraintlayout.widget.ConstraintLayout>
18
+ <!-- Safe margin area at the bottom - initially hidden -->
19
+ <View
20
+ android:id="@+id/safe_margin_bottom"
21
+ android:layout_width="match_parent"
22
+ android:layout_height="0dp"
23
+ android:layout_alignParentBottom="true"
24
+ android:layout_alignParentLeft="true"
25
+ android:layout_alignParentRight="true"
26
+ android:background="@android:color/transparent" />
27
+
28
+ </RelativeLayout>
package/dist/docs.json CHANGED
@@ -1081,6 +1081,66 @@
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": "enabledSafeMargin",
1087
+ "tags": [
1088
+ {
1089
+ "text": "7.13.0",
1090
+ "name": "since"
1091
+ },
1092
+ {
1093
+ "text": "false",
1094
+ "name": "default"
1095
+ },
1096
+ {
1097
+ "text": "enabledSafeMargin: true",
1098
+ "name": "example"
1099
+ }
1100
+ ],
1101
+ "docs": "If true, the webView will not take the full height and will have a 20px margin at the bottom.\nThis creates a safe margin area outside the browser view.",
1102
+ "complexTypes": [],
1103
+ "type": "boolean | undefined"
1104
+ },
1105
+ {
1106
+ "name": "safeMargin",
1107
+ "tags": [
1108
+ {
1109
+ "text": "7.13.0",
1110
+ "name": "since"
1111
+ },
1112
+ {
1113
+ "text": "20",
1114
+ "name": "default"
1115
+ },
1116
+ {
1117
+ "text": "safeMargin: 30",
1118
+ "name": "example"
1119
+ }
1120
+ ],
1121
+ "docs": "Custom safe margin value in pixels. Only used when enabledSafeMargin is true.\nIf not specified, defaults to 20px.",
1122
+ "complexTypes": [],
1123
+ "type": "number | undefined"
1124
+ },
1125
+ {
1126
+ "name": "enableGooglePaySupport",
1127
+ "tags": [
1128
+ {
1129
+ "text": "7.13.0",
1130
+ "name": "since"
1131
+ },
1132
+ {
1133
+ "text": "false",
1134
+ "name": "default"
1135
+ },
1136
+ {
1137
+ "text": "enableGooglePaySupport: true\nTest URL: https://developers.google.com/pay/api/web/guides/tutorial",
1138
+ "name": "example"
1139
+ }
1140
+ ],
1141
+ "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",
1142
+ "complexTypes": [],
1143
+ "type": "boolean | undefined"
1084
1144
  }
1085
1145
  ]
1086
1146
  },
@@ -416,6 +416,42 @@ export interface OpenWebViewOptions {
416
416
  * @default []
417
417
  */
418
418
  authorizedAppLinks?: string[];
419
+ /**
420
+ * If true, the webView will not take the full height and will have a 20px margin at the bottom.
421
+ * This creates a safe margin area outside the browser view.
422
+ * @since 7.13.0
423
+ * @default false
424
+ * @example
425
+ * enabledSafeMargin: true
426
+ */
427
+ enabledSafeMargin?: boolean;
428
+ /**
429
+ * Custom safe margin value in pixels. Only used when enabledSafeMargin is true.
430
+ * If not specified, defaults to 20px.
431
+ * @since 7.13.0
432
+ * @default 20
433
+ * @example
434
+ * safeMargin: 30
435
+ */
436
+ safeMargin?: number;
437
+ /**
438
+ * enableGooglePaySupport: if true, enables support for Google Pay popups and Payment Request API.
439
+ * This fixes OR_BIBED_15 errors by allowing popup windows and configuring Cross-Origin-Opener-Policy.
440
+ * Only enable this if you need Google Pay functionality as it allows popup windows.
441
+ *
442
+ * When enabled:
443
+ * - Allows popup windows for Google Pay authentication
444
+ * - Sets proper CORS headers for Payment Request API
445
+ * - Enables multiple window support in WebView
446
+ * - Configures secure context for payment processing
447
+ *
448
+ * @since 7.13.0
449
+ * @default false
450
+ * @example
451
+ * enableGooglePaySupport: true
452
+ * Test URL: https://developers.google.com/pay/api/web/guides/tutorial
453
+ */
454
+ enableGooglePaySupport?: boolean;
419
455
  }
420
456
  export interface InAppBrowserPlugin {
421
457
  /**
@@ -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 * If true, the webView will not take the full height and will have a 20px margin at the bottom.\n * This creates a safe margin area outside the browser view.\n * @since 7.13.0\n * @default false\n * @example\n * enabledSafeMargin: true\n */\n enabledSafeMargin?: boolean;\n\n /**\n * Custom safe margin value in pixels. Only used when enabledSafeMargin is true.\n * If not specified, defaults to 20px.\n * @since 7.13.0\n * @default 20\n * @example\n * safeMargin: 30\n */\n safeMargin?: number;\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"]}
@@ -290,6 +290,8 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
290
290
  let isInspectable = call.getBool("isInspectable", false)
291
291
  let preventDeeplink = call.getBool("preventDeeplink", false)
292
292
  let isAnimated = call.getBool("isAnimated", true)
293
+ let enabledSafeMargin = call.getBool("enabledSafeMargin", false)
294
+ let safeMargin = call.getDouble("safeMargin", 20.0)
293
295
 
294
296
  // Validate preShowScript requires isPresentAfterPageLoad
295
297
  if call.getString("preShowScript") != nil && !call.getBool("isPresentAfterPageLoad", false) {
@@ -349,6 +351,7 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
349
351
  // }
350
352
 
351
353
  let ignoreUntrustedSSLError = call.getBool("ignoreUntrustedSSLError", false)
354
+ let enableGooglePaySupport = call.getBool("enableGooglePaySupport", false)
352
355
 
353
356
  self.isPresentAfterPageLoad = call.getBool("isPresentAfterPageLoad", false)
354
357
  let showReloadButton = call.getBool("showReloadButton", false)
@@ -361,7 +364,7 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
361
364
  return
362
365
  }
363
366
 
364
- self.webViewController = WKWebViewController.init(url: url, headers: headers, isInspectable: isInspectable, credentials: credentials, preventDeeplink: preventDeeplink, blankNavigationTab: toolbarType == "blank")
367
+ self.webViewController = WKWebViewController.init(url: url, headers: headers, isInspectable: isInspectable, credentials: credentials, preventDeeplink: preventDeeplink, blankNavigationTab: toolbarType == "blank", enabledSafeMargin: enabledSafeMargin, safeMargin: safeMargin)
365
368
 
366
369
  guard let webViewController = self.webViewController else {
367
370
  call.reject("Failed to initialize WebViewController")
@@ -470,6 +473,9 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
470
473
  webViewController.websiteTitleInNavigationBar = call.getBool("visibleTitle", true)
471
474
  webViewController.ignoreUntrustedSSLError = ignoreUntrustedSSLError
472
475
 
476
+ // Set Google Pay support
477
+ webViewController.enableGooglePaySupport = enableGooglePaySupport
478
+
473
479
  // Set text zoom if specified
474
480
  if let textZoom = call.getInt("textZoom") {
475
481
  webViewController.textZoom = textZoom
@@ -689,7 +695,7 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
689
695
  return
690
696
  }
691
697
 
692
- self.webViewController = WKWebViewController.init(url: url, headers: headers, isInspectable: isInspectable, credentials: credentials, preventDeeplink: preventDeeplink, blankNavigationTab: true)
698
+ self.webViewController = WKWebViewController.init(url: url, headers: headers, isInspectable: isInspectable, credentials: credentials, preventDeeplink: preventDeeplink, blankNavigationTab: true, enabledSafeMargin: false, safeMargin: 20.0)
693
699
 
694
700
  guard let webViewController = self.webViewController else {
695
701
  call.reject("Failed to initialize WebViewController")
@@ -76,9 +76,11 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
76
76
  self.initWebview(isInspectable: isInspectable)
77
77
  }
78
78
 
79
- public init(url: URL, headers: [String: String], isInspectable: Bool, credentials: WKWebViewCredentials? = nil, preventDeeplink: Bool, blankNavigationTab: Bool) {
79
+ public init(url: URL, headers: [String: String], isInspectable: Bool, credentials: WKWebViewCredentials? = nil, preventDeeplink: Bool, blankNavigationTab: Bool, enabledSafeMargin: Bool, safeMargin: CGFloat) {
80
80
  super.init(nibName: nil, bundle: nil)
81
81
  self.blankNavigationTab = blankNavigationTab
82
+ self.enabledSafeMargin = enabledSafeMargin
83
+ self.safeMargin = safeMargin
82
84
  self.source = .remote(url)
83
85
  self.credentials = credentials
84
86
  self.setHeaders(headers: headers)
@@ -109,10 +111,13 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
109
111
  open var closeModalOk = ""
110
112
  open var closeModalCancel = ""
111
113
  open var ignoreUntrustedSSLError = false
114
+ open var enableGooglePaySupport = false
112
115
  var viewWasPresented = false
113
116
  var preventDeeplink: Bool = false
114
117
  var blankNavigationTab: Bool = false
115
118
  var capacitorStatusBar: UIView?
119
+ var enabledSafeMargin: Bool = false
120
+ var safeMargin: CGFloat = 20.0 // Default safe margin in points
116
121
 
117
122
  internal var preShowSemaphore: DispatchSemaphore?
118
123
  internal var preShowError: String?
@@ -448,12 +453,12 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
448
453
  print("[InAppBrowser] Failed to serialize message to JSON")
449
454
  return
450
455
  }
451
-
456
+
452
457
  // Safely build the script to avoid any potential issues
453
458
  let script = "window.dispatchEvent(new CustomEvent('messageFromNative', { detail: \(jsonString) }));"
454
-
459
+
455
460
  DispatchQueue.main.async {
456
- self.webView?.evaluateJavaScript(script) { result, error in
461
+ self.webView?.evaluateJavaScript(script) { _, error in
457
462
  if let error = error {
458
463
  print("[InAppBrowser] JavaScript evaluation error in postMessageToJS: \(error)")
459
464
  }
@@ -562,6 +567,56 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
562
567
  webConfiguration.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs")
563
568
  webConfiguration.setValue(true, forKey: "allowUniversalAccessFromFileURLs")
564
569
 
570
+ // Enhanced configuration for Google Pay support (only when enabled)
571
+ if enableGooglePaySupport {
572
+ print("[InAppBrowser] Enabling Google Pay support features for iOS")
573
+
574
+ // Allow arbitrary loads in web views for Payment Request API
575
+ webConfiguration.setValue(true, forKey: "allowsArbitraryLoads")
576
+
577
+ // Enable JavaScript popup support for Google Pay
578
+ webConfiguration.preferences.javaScriptCanOpenWindowsAutomatically = true
579
+
580
+ // Inject Google Pay support script
581
+ let googlePayScript = WKUserScript(
582
+ source: """
583
+ console.log('[InAppBrowser] Injecting Google Pay support for iOS');
584
+
585
+ // Enhanced window.open for Google Pay
586
+ (function() {
587
+ const originalWindowOpen = window.open;
588
+ window.open = function(url, target, features) {
589
+ console.log('[InAppBrowser iOS] Enhanced window.open called:', url, target, features);
590
+
591
+ // For Google Pay URLs, handle popup properly
592
+ if (url && (url.includes('google.com/pay') || url.includes('accounts.google.com'))) {
593
+ console.log('[InAppBrowser iOS] Google Pay popup detected');
594
+ return originalWindowOpen.call(window, url, target || '_blank', features);
595
+ }
596
+
597
+ return originalWindowOpen.call(window, url, target, features);
598
+ };
599
+
600
+ // Add Cross-Origin-Opener-Policy meta tag if not present
601
+ if (!document.querySelector('meta[http-equiv="Cross-Origin-Opener-Policy"]')) {
602
+ const meta = document.createElement('meta');
603
+ meta.setAttribute('http-equiv', 'Cross-Origin-Opener-Policy');
604
+ meta.setAttribute('content', 'same-origin-allow-popups');
605
+ if (document.head) {
606
+ document.head.appendChild(meta);
607
+ console.log('[InAppBrowser iOS] Added Cross-Origin-Opener-Policy meta tag');
608
+ }
609
+ }
610
+
611
+ console.log('[InAppBrowser iOS] Google Pay support enhancements complete');
612
+ })();
613
+ """,
614
+ injectionTime: .atDocumentStart,
615
+ forMainFrameOnly: false
616
+ )
617
+ userContentController.addUserScript(googlePayScript)
618
+ }
619
+
565
620
  let webView = WKWebView(frame: .zero, configuration: webConfiguration)
566
621
 
567
622
  // if webView.responds(to: Selector(("setInspectable:"))) {
@@ -575,12 +630,22 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
575
630
  // Fallback on earlier versions
576
631
  }
577
632
 
578
- if self.blankNavigationTab {
579
- // First add the webView to view hierarchy
580
- self.view.addSubview(webView)
633
+ // First add the webView to view hierarchy
634
+ self.view.addSubview(webView)
581
635
 
582
- // Then set up constraints
583
- webView.translatesAutoresizingMaskIntoConstraints = false
636
+ // Then set up constraints
637
+ webView.translatesAutoresizingMaskIntoConstraints = false
638
+
639
+ if self.enabledSafeMargin {
640
+ // Add custom safe margin when enabled
641
+ NSLayoutConstraint.activate([
642
+ webView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor),
643
+ webView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
644
+ webView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor),
645
+ webView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor, constant: -self.safeMargin)
646
+ ])
647
+ } else {
648
+ // Normal full height layout
584
649
  NSLayoutConstraint.activate([
585
650
  webView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor),
586
651
  webView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor),
@@ -602,7 +667,28 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
602
667
  webView.addObserver(self, forKeyPath: #keyPath(WKWebView.url), options: .new, context: nil)
603
668
 
604
669
  if !self.blankNavigationTab {
605
- self.view = webView
670
+ // For non-blank navigation tab, we need to handle enabledSafeMargin differently
671
+ if self.enabledSafeMargin {
672
+ // Create a container view to hold the webView with margin
673
+ let containerView = UIView()
674
+ containerView.translatesAutoresizingMaskIntoConstraints = false
675
+ self.view = containerView
676
+
677
+ // Add webView to container
678
+ containerView.addSubview(webView)
679
+ webView.translatesAutoresizingMaskIntoConstraints = false
680
+
681
+ // Set constraints with custom safe margin
682
+ NSLayoutConstraint.activate([
683
+ webView.topAnchor.constraint(equalTo: containerView.topAnchor),
684
+ webView.leadingAnchor.constraint(equalTo: containerView.leadingAnchor),
685
+ webView.trailingAnchor.constraint(equalTo: containerView.trailingAnchor),
686
+ webView.bottomAnchor.constraint(equalTo: containerView.bottomAnchor, constant: -self.safeMargin)
687
+ ])
688
+ } else {
689
+ // Normal behavior - webView is the entire view
690
+ self.view = webView
691
+ }
606
692
  }
607
693
  self.webView = webView
608
694
 
@@ -667,7 +753,8 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
667
753
 
668
754
  override open func viewWillLayoutSubviews() {
669
755
  restateViewHeight()
670
- if self.currentViewHeight != nil {
756
+ // Don't override frame height when enabledSafeMargin is true, as it would override our constraints
757
+ if self.currentViewHeight != nil && !self.enabledSafeMargin {
671
758
  self.view.frame.size.height = self.currentViewHeight!
672
759
  }
673
760
  }
@@ -1350,7 +1437,7 @@ extension WKWebViewController: WKNavigationDelegate {
1350
1437
 
1351
1438
  // Safely construct script template with proper escaping
1352
1439
  let userScript = self.preShowScript ?? ""
1353
-
1440
+
1354
1441
  // Build script using safe concatenation to avoid multi-line string issues
1355
1442
  let scriptTemplate = [
1356
1443
  "async function preShowFunction() {",
@@ -1365,7 +1452,7 @@ extension WKWebViewController: WKNavigationDelegate {
1365
1452
  " }",
1366
1453
  ")"
1367
1454
  ]
1368
-
1455
+
1369
1456
  let script = scriptTemplate.joined(separator: "\n")
1370
1457
  print("[InAppBrowser - InjectPreShowScript] PreShowScript script: \(script)")
1371
1458
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "7.12.1",
3
+ "version": "7.14.0",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",