@capgo/inappbrowser 7.27.0 → 7.27.2

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.
@@ -60,4 +60,5 @@ dependencies {
60
60
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
61
61
  implementation "androidx.browser:browser:$androidxBrowserVersion"
62
62
  implementation 'com.google.android.material:material:1.13.0'
63
+ implementation 'androidx.webkit:webkit:1.14.0'
63
64
  }
@@ -50,7 +50,7 @@ import org.json.JSONObject;
50
50
  )
51
51
  public class InAppBrowserPlugin extends Plugin implements WebViewDialog.PermissionHandler {
52
52
 
53
- private final String PLUGIN_VERSION = "7.27.0";
53
+ private final String PLUGIN_VERSION = "7.27.2";
54
54
 
55
55
  public static final String CUSTOM_TAB_PACKAGE_NAME = "com.android.chrome"; // Change when in stable
56
56
  private CustomTabsClient customTabsClient;
@@ -57,6 +57,8 @@ import androidx.core.graphics.Insets;
57
57
  import androidx.core.view.ViewCompat;
58
58
  import androidx.core.view.WindowInsetsCompat;
59
59
  import androidx.core.view.WindowInsetsControllerCompat;
60
+ import androidx.webkit.WebSettingsCompat;
61
+ import androidx.webkit.WebViewFeature;
60
62
  import com.caverock.androidsvg.SVG;
61
63
  import com.caverock.androidsvg.SVGParseException;
62
64
  import com.getcapacitor.JSObject;
@@ -356,6 +358,11 @@ public class WebViewDialog extends Dialog {
356
358
  _webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
357
359
  _webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
358
360
 
361
+ // Open links in external browser for target="_blank" if preventDeepLink is false
362
+ if (!_options.getPreventDeeplink()) {
363
+ _webView.getSettings().setSupportMultipleWindows(true);
364
+ }
365
+
359
366
  // Enhanced settings for Google Pay and Payment Request API support (only when enabled)
360
367
  if (_options.getEnableGooglePaySupport()) {
361
368
  Log.d("InAppBrowser", "Enabling Google Pay support features");
@@ -367,6 +374,14 @@ public class WebViewDialog extends Dialog {
367
374
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
368
375
  _webView.getSettings().setMixedContentMode(android.webkit.WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
369
376
  }
377
+
378
+ // Enable Payment Request API only if feature is supported
379
+ if (WebViewFeature.isFeatureSupported(WebViewFeature.PAYMENT_REQUEST)) {
380
+ WebSettingsCompat.setPaymentRequestEnabled(_webView.getSettings(), true);
381
+ Log.d("InAppBrowser", "Payment Request API enabled");
382
+ } else {
383
+ Log.d("InAppBrowser", "Payment Request API not supported on this device");
384
+ }
370
385
  }
371
386
 
372
387
  // Set web view background color
@@ -737,9 +752,28 @@ public class WebViewDialog extends Dialog {
737
752
  "onCreateWindow called - isUserGesture: " +
738
753
  isUserGesture +
739
754
  ", GooglePaySupport: " +
740
- _options.getEnableGooglePaySupport()
755
+ _options.getEnableGooglePaySupport() +
756
+ ", preventDeeplink: " +
757
+ _options.getPreventDeeplink()
741
758
  );
742
759
 
760
+ // When preventDeeplink is false, open target="_blank" links externally
761
+ if (!_options.getPreventDeeplink() && isUserGesture) {
762
+ try {
763
+ WebView.HitTestResult result = view.getHitTestResult();
764
+ String data = result.getExtra();
765
+ if (data != null && !data.isEmpty()) {
766
+ Log.d("InAppBrowser", "Opening target=_blank link externally: " + data);
767
+ Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(data));
768
+ browserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
769
+ _webView.getContext().startActivity(browserIntent);
770
+ return false;
771
+ }
772
+ } catch (Exception e) {
773
+ Log.e("InAppBrowser", "Error opening external link: " + e.getMessage());
774
+ }
775
+ }
776
+
743
777
  // Only handle popup windows if Google Pay support is enabled
744
778
  if (_options.getEnableGooglePaySupport() && isUserGesture) {
745
779
  // Create a new WebView for the popup
@@ -24,7 +24,7 @@ extension UIColor {
24
24
  */
25
25
  @objc(InAppBrowserPlugin)
26
26
  public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
27
- private let PLUGIN_VERSION: String = "7.27.0"
27
+ private let PLUGIN_VERSION: String = "7.27.2"
28
28
  public let identifier = "InAppBrowserPlugin"
29
29
  public let jsName = "InAppBrowser"
30
30
  public let pluginMethods: [CAPPluginMethod] = [
@@ -1578,6 +1578,29 @@ extension WKWebViewController: WKUIDelegate {
1578
1578
  }
1579
1579
  }
1580
1580
  }
1581
+
1582
+ public func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
1583
+ // Handle target="_blank" links and popup windows
1584
+ // When preventDeeplink is true, we should load these in the same webview instead of opening externally
1585
+ if let url = navigationAction.request.url {
1586
+ print("[InAppBrowser] Handling popup/new window request for URL: \(url.absoluteString)")
1587
+
1588
+ // If preventDeeplink is true, load the URL in the current webview
1589
+ if preventDeeplink {
1590
+ print("[InAppBrowser] preventDeeplink is true, loading popup URL in current webview")
1591
+ DispatchQueue.main.async { [weak self] in
1592
+ self?.load(remote: url)
1593
+ }
1594
+ return nil
1595
+ }
1596
+
1597
+ // Otherwise, check if we should handle it externally
1598
+ // But since preventDeeplink is false here, we won't block it
1599
+ return nil
1600
+ }
1601
+
1602
+ return nil
1603
+ }
1581
1604
  }
1582
1605
 
1583
1606
  // MARK: - Host Blocking Utilities
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "7.27.0",
3
+ "version": "7.27.2",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",