@capgo/inappbrowser 6.8.10 → 6.8.13

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.
@@ -12,7 +12,7 @@ buildscript {
12
12
  mavenCentral()
13
13
  }
14
14
  dependencies {
15
- classpath 'com.android.tools.build:gradle:8.2.1'
15
+ classpath 'com.android.tools.build:gradle:8.7.1'
16
16
  }
17
17
  }
18
18
 
@@ -272,16 +272,16 @@ open class WKWebViewController: UIViewController, WKScriptMessageHandler {
272
272
 
273
273
  func injectJavaScriptInterface() {
274
274
  let script = """
275
- if (!window.mobileApp) {
276
- window.mobileApp = {
277
- postMessage: function(message) {
278
- if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.messageHandler) {
279
- window.webkit.messageHandlers.messageHandler.postMessage(message);
280
- }
275
+ if (!window.mobileApp) {
276
+ window.mobileApp = {
277
+ postMessage: function(message) {
278
+ if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.messageHandler) {
279
+ window.webkit.messageHandlers.messageHandler.postMessage(message);
280
+ }
281
+ }
282
+ };
281
283
  }
282
- };
283
- }
284
- """
284
+ """
285
285
  DispatchQueue.main.async {
286
286
  self.webView?.evaluateJavaScript(script, completionHandler: nil)
287
287
  }
@@ -850,18 +850,18 @@ extension WKWebViewController: WKNavigationDelegate {
850
850
 
851
851
  // TODO: implement interface
852
852
  let script = """
853
- async function preShowFunction() {
854
- \(self.preShowScript ?? "")
855
- };
856
- preShowFunction().then(
857
- () => window.webkit.messageHandlers.preShowScriptSuccess.postMessage({})
858
- ).catch(
859
- err => {
860
- console.error('Preshow error', err);
861
- window.webkit.messageHandlers.preShowScriptError.postMessage(JSON.stringify(err, Object.getOwnPropertyNames(err)));
862
- }
863
- )
864
- """
853
+ async function preShowFunction() {
854
+ \(self.preShowScript ?? "")
855
+ };
856
+ preShowFunction().then(
857
+ () => window.webkit.messageHandlers.preShowScriptSuccess.postMessage({})
858
+ ).catch(
859
+ err => {
860
+ console.error('Preshow error', err);
861
+ window.webkit.messageHandlers.preShowScriptError.postMessage(JSON.stringify(err, Object.getOwnPropertyNames(err)));
862
+ }
863
+ )
864
+ """
865
865
  print("[InAppBrowser - InjectPreShowScript] PreShowScript script: \(script)")
866
866
 
867
867
  self.preShowSemaphore = DispatchSemaphore(value: 0)
@@ -975,11 +975,16 @@ extension WKWebViewController: WKNavigationDelegate {
975
975
  actionPolicy = .preventDeeplinkActionPolicy
976
976
  }
977
977
 
978
- defer {
978
+ guard let u = navigationAction.request.url else {
979
979
  decisionHandler(actionPolicy)
980
+ return
980
981
  }
981
- guard let u = navigationAction.request.url else {
982
- print("Cannot handle empty URLs")
982
+
983
+ // Check if the URL is an App Store URL
984
+ if u.absoluteString.contains("apps.apple.com") {
985
+ UIApplication.shared.open(u, options: [:], completionHandler: nil)
986
+ // Cancel the navigation in the web view
987
+ decisionHandler(.cancel)
983
988
  return
984
989
  }
985
990
 
@@ -1003,6 +1008,7 @@ extension WKWebViewController: WKNavigationDelegate {
1003
1008
  actionPolicy = result ? .allow : .cancel
1004
1009
  }
1005
1010
  self.injectJavaScriptInterface()
1011
+ decisionHandler(actionPolicy)
1006
1012
  }
1007
1013
  }
1008
1014
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/inappbrowser",
3
- "version": "6.8.10",
3
+ "version": "6.8.13",
4
4
  "description": "Capacitor plugin in app browser",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",