@capgo/capacitor-inappbrowser 8.6.30 → 8.6.31
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.
|
@@ -2,6 +2,7 @@ package ee.forgr.capacitor_inappbrowser;
|
|
|
2
2
|
|
|
3
3
|
import android.Manifest;
|
|
4
4
|
import android.app.Activity;
|
|
5
|
+
import android.content.ActivityNotFoundException;
|
|
5
6
|
import android.content.ComponentName;
|
|
6
7
|
import android.content.Intent;
|
|
7
8
|
import android.content.pm.PackageManager;
|
|
@@ -763,7 +764,26 @@ public class CapgoInAppBrowserPlugin extends Plugin implements WebViewDialog.Per
|
|
|
763
764
|
tabsIntent.intent.putExtra("isPresentAfterPageLoad", true);
|
|
764
765
|
}
|
|
765
766
|
|
|
766
|
-
|
|
767
|
+
Uri targetUri = Uri.parse(url);
|
|
768
|
+
try {
|
|
769
|
+
tabsIntent.launchUrl(getContext(), targetUri);
|
|
770
|
+
} catch (ActivityNotFoundException e) {
|
|
771
|
+
Intent fallback = new Intent(Intent.ACTION_VIEW, targetUri);
|
|
772
|
+
fallback.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
773
|
+
Bundle extras = tabsIntent.intent.getExtras();
|
|
774
|
+
if (extras != null) {
|
|
775
|
+
fallback.putExtras(extras);
|
|
776
|
+
}
|
|
777
|
+
if (tabsIntent.intent.getPackage() != null) {
|
|
778
|
+
fallback.setPackage(tabsIntent.intent.getPackage());
|
|
779
|
+
}
|
|
780
|
+
try {
|
|
781
|
+
getContext().startActivity(fallback);
|
|
782
|
+
} catch (ActivityNotFoundException e2) {
|
|
783
|
+
call.reject("No browser found to open URL: " + url);
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
767
787
|
|
|
768
788
|
call.resolve();
|
|
769
789
|
}
|
|
@@ -98,7 +98,7 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
98
98
|
case aware = "AWARE"
|
|
99
99
|
case fakeVisible = "FAKE_VISIBLE"
|
|
100
100
|
}
|
|
101
|
-
private let pluginVersion: String = "8.6.
|
|
101
|
+
private let pluginVersion: String = "8.6.31"
|
|
102
102
|
public let identifier = "CapgoInAppBrowserPlugin"
|
|
103
103
|
public let jsName = "CapgoInAppBrowser"
|
|
104
104
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -250,9 +250,7 @@ public class CapgoInAppBrowserPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
250
250
|
) -> WKWebView? {
|
|
251
251
|
let popupId = UUID().uuidString
|
|
252
252
|
let shouldHidePopup = parentController.hiddenPopupWindow
|
|
253
|
-
|
|
254
|
-
configuration.processPool = parentWebView.configuration.processPool
|
|
255
|
-
}
|
|
253
|
+
// WKProcessPool sharing is automatic on iOS 15+; explicit assignment is deprecated.
|
|
256
254
|
if let dataStore = parentController.websiteDataStore() {
|
|
257
255
|
configuration.websiteDataStore = dataStore
|
|
258
256
|
}
|
|
@@ -687,7 +687,13 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
687
687
|
|
|
688
688
|
// Status bar height
|
|
689
689
|
private var statusBarHeight: CGFloat {
|
|
690
|
-
|
|
690
|
+
let windowScene = UIApplication.shared.connectedScenes
|
|
691
|
+
.compactMap { $0 as? UIWindowScene }
|
|
692
|
+
.first { $0.activationState == .foregroundActive }
|
|
693
|
+
?? UIApplication.shared.connectedScenes
|
|
694
|
+
.compactMap { $0 as? UIWindowScene }
|
|
695
|
+
.first
|
|
696
|
+
return windowScene?.statusBarManager?.statusBarFrame.height ?? 0
|
|
691
697
|
}
|
|
692
698
|
|
|
693
699
|
// Make status bar background with colored view underneath
|
|
@@ -1405,9 +1411,7 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
1405
1411
|
webConfiguration.allowsInlineMediaPlayback = true
|
|
1406
1412
|
webConfiguration.userContentController = userContentController
|
|
1407
1413
|
// Enable background task processing
|
|
1408
|
-
|
|
1409
|
-
webConfiguration.processPool = WKProcessPool()
|
|
1410
|
-
}
|
|
1414
|
+
// WKProcessPool is shared automatically on iOS 15+; explicit assignment is deprecated.
|
|
1411
1415
|
|
|
1412
1416
|
// Enable JavaScript to run automatically (needed for preShowScript and Firebase polyfill)
|
|
1413
1417
|
webConfiguration.preferences.javaScriptCanOpenWindowsAutomatically = true
|
|
@@ -1629,7 +1633,7 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
1629
1633
|
|
|
1630
1634
|
// Ensure status bar appearance is correct when view appears
|
|
1631
1635
|
// Make sure we have the latest tint color
|
|
1632
|
-
if
|
|
1636
|
+
if self.tintColor != nil {
|
|
1633
1637
|
// Update the status bar background if needed
|
|
1634
1638
|
if let navController = navigationController, let backgroundColor = navController.navigationBar.backgroundColor ?? statusBarBackgroundView?.backgroundColor {
|
|
1635
1639
|
setupStatusBarBackground(color: backgroundColor)
|
|
@@ -1735,6 +1739,15 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
|
|
|
1735
1739
|
// MARK: - Public Methods
|
|
1736
1740
|
public extension WKWebViewController {
|
|
1737
1741
|
|
|
1742
|
+
func goBack() -> Bool {
|
|
1743
|
+
if webView?.canGoBack ?? false {
|
|
1744
|
+
webView?.goBack()
|
|
1745
|
+
return true
|
|
1746
|
+
}
|
|
1747
|
+
return false
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
|
|
1738
1751
|
func load(source sourceValue: WKWebSource) {
|
|
1739
1752
|
switch sourceValue {
|
|
1740
1753
|
case .remote(let url):
|
|
@@ -1816,7 +1829,7 @@ public extension WKWebViewController {
|
|
|
1816
1829
|
self.webView?.allowsBackForwardNavigationGestures = self.activeNativeNavigationForWebview
|
|
1817
1830
|
}
|
|
1818
1831
|
|
|
1819
|
-
|
|
1832
|
+
func cleanupWebView() {
|
|
1820
1833
|
guard let webView = self.webView else { return }
|
|
1821
1834
|
webView.stopLoading()
|
|
1822
1835
|
previewItemURL = nil
|
|
@@ -2264,14 +2277,6 @@ fileprivate extension WKWebViewController {
|
|
|
2264
2277
|
}
|
|
2265
2278
|
|
|
2266
2279
|
// Public method for safe back navigation
|
|
2267
|
-
public func goBack() -> Bool {
|
|
2268
|
-
if webView?.canGoBack ?? false {
|
|
2269
|
-
webView?.goBack()
|
|
2270
|
-
return true
|
|
2271
|
-
}
|
|
2272
|
-
return false
|
|
2273
|
-
}
|
|
2274
|
-
|
|
2275
2280
|
@objc func forwardDidClick(sender: AnyObject) {
|
|
2276
2281
|
webView?.goForward()
|
|
2277
2282
|
}
|
|
@@ -2422,7 +2427,7 @@ fileprivate extension WKWebViewController {
|
|
|
2422
2427
|
dismiss(animated: true, completion: nil)
|
|
2423
2428
|
}
|
|
2424
2429
|
|
|
2425
|
-
|
|
2430
|
+
func setUpNavigationBarAppearance() {
|
|
2426
2431
|
// Set up basic bar appearance
|
|
2427
2432
|
if let navBar = navigationController?.navigationBar {
|
|
2428
2433
|
// Make navigation bar transparent
|
|
@@ -2479,15 +2484,7 @@ extension WKWebViewController: WKUIDelegate {
|
|
|
2479
2484
|
strongCompletionHandler()
|
|
2480
2485
|
}))
|
|
2481
2486
|
|
|
2482
|
-
|
|
2483
|
-
do {
|
|
2484
|
-
self.present(alertController, animated: true, completion: nil)
|
|
2485
|
-
} catch {
|
|
2486
|
-
// This won't typically be triggered as present doesn't throw,
|
|
2487
|
-
// but adding as a safeguard
|
|
2488
|
-
print("[InAppBrowser] Error presenting alert: \(error)")
|
|
2489
|
-
strongCompletionHandler()
|
|
2490
|
-
}
|
|
2487
|
+
self.present(alertController, animated: true, completion: nil)
|
|
2491
2488
|
}
|
|
2492
2489
|
}
|
|
2493
2490
|
|
|
@@ -2880,7 +2877,7 @@ extension WKWebViewController: WKNavigationDelegate {
|
|
|
2880
2877
|
// MARK: - Dimension Management
|
|
2881
2878
|
|
|
2882
2879
|
/// Apply custom dimensions to the view if specified
|
|
2883
|
-
|
|
2880
|
+
func applyCustomDimensions() {
|
|
2884
2881
|
guard let navigationController = navigationController,
|
|
2885
2882
|
let targetFrame = CustomWebViewFrameSupport.resolvedFrame(
|
|
2886
2883
|
width: customWidth,
|
|
@@ -2910,7 +2907,7 @@ extension WKWebViewController: WKNavigationDelegate {
|
|
|
2910
2907
|
}
|
|
2911
2908
|
|
|
2912
2909
|
/// Update dimensions at runtime
|
|
2913
|
-
|
|
2910
|
+
func updateDimensions(width: CGFloat?, height: CGFloat?, xPos: CGFloat?, yPos: CGFloat?) {
|
|
2914
2911
|
// Update stored dimensions
|
|
2915
2912
|
if let width = width {
|
|
2916
2913
|
customWidth = width
|
|
@@ -2929,7 +2926,7 @@ extension WKWebViewController: WKNavigationDelegate {
|
|
|
2929
2926
|
applyCustomDimensions()
|
|
2930
2927
|
}
|
|
2931
2928
|
|
|
2932
|
-
|
|
2929
|
+
func updateSafeTopMargin(_ enabled: Bool) {
|
|
2933
2930
|
guard enabled != self.enabledSafeTopMargin else { return }
|
|
2934
2931
|
self.enabledSafeTopMargin = enabled
|
|
2935
2932
|
guard let webView = self.webView else { return }
|
|
@@ -2950,7 +2947,7 @@ extension WKWebViewController: WKNavigationDelegate {
|
|
|
2950
2947
|
refreshWebViewViewportIfNeeded(force: true)
|
|
2951
2948
|
}
|
|
2952
2949
|
|
|
2953
|
-
|
|
2950
|
+
func updateSafeBottomMargin(_ enabled: Bool) {
|
|
2954
2951
|
guard enabled != self.enabledSafeBottomMargin else { return }
|
|
2955
2952
|
self.enabledSafeBottomMargin = enabled
|
|
2956
2953
|
guard let webView = self.webView else { return }
|