@capgo/inappbrowser 7.27.1 → 7.27.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.1";
53
+ private final String pluginVersion = "7.27.3";
54
54
 
55
55
  public static final String CUSTOM_TAB_PACKAGE_NAME = "com.android.chrome"; // Change when in stable
56
56
  private CustomTabsClient customTabsClient;
@@ -924,7 +924,7 @@ public class InAppBrowserPlugin extends Plugin implements WebViewDialog.Permissi
924
924
  public void getPluginVersion(final PluginCall call) {
925
925
  try {
926
926
  final JSObject ret = new JSObject();
927
- ret.put("version", this.PLUGIN_VERSION);
927
+ ret.put("version", this.pluginVersion);
928
928
  call.resolve(ret);
929
929
  } catch (final Exception e) {
930
930
  call.reject("Could not get plugin version", e);
@@ -358,6 +358,11 @@ public class WebViewDialog extends Dialog {
358
358
  _webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
359
359
  _webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
360
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
+
361
366
  // Enhanced settings for Google Pay and Payment Request API support (only when enabled)
362
367
  if (_options.getEnableGooglePaySupport()) {
363
368
  Log.d("InAppBrowser", "Enabling Google Pay support features");
@@ -747,9 +752,28 @@ public class WebViewDialog extends Dialog {
747
752
  "onCreateWindow called - isUserGesture: " +
748
753
  isUserGesture +
749
754
  ", GooglePaySupport: " +
750
- _options.getEnableGooglePaySupport()
755
+ _options.getEnableGooglePaySupport() +
756
+ ", preventDeeplink: " +
757
+ _options.getPreventDeeplink()
751
758
  );
752
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
+
753
777
  // Only handle popup windows if Google Pay support is enabled
754
778
  if (_options.getEnableGooglePaySupport() && isUserGesture) {
755
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.1"
27
+ private let pluginVersion: String = "7.27.3"
28
28
  public let identifier = "InAppBrowserPlugin"
29
29
  public let jsName = "InAppBrowser"
30
30
  public let pluginMethods: [CAPPluginMethod] = [
@@ -862,7 +862,7 @@ public class InAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
862
862
  }
863
863
 
864
864
  @objc func getPluginVersion(_ call: CAPPluginCall) {
865
- call.resolve(["version": self.PLUGIN_VERSION])
865
+ call.resolve(["version": self.pluginVersion])
866
866
  }
867
867
 
868
868
  }
@@ -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.1",
3
+ "version": "7.27.3",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",