Skip to content

Commit

Permalink
fix: issue with apple link
Browse files Browse the repository at this point in the history
  • Loading branch information
riderx committed Oct 18, 2024
1 parent 13baab7 commit b730cbc
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ios/Plugin/WKWebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -975,11 +975,16 @@ extension WKWebViewController: WKNavigationDelegate {
actionPolicy = .preventDeeplinkActionPolicy
}

defer {
guard let url = navigationAction.request.url else {
decisionHandler(actionPolicy)
return
}
guard let u = navigationAction.request.url else {
print("Cannot handle empty URLs")

// Check if the URL is an App Store URL
if url.absoluteString.contains("apps.apple.com") {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
// Cancel the navigation in the web view
decisionHandler(.cancel)
return
}

Expand All @@ -1003,6 +1008,7 @@ extension WKWebViewController: WKNavigationDelegate {
actionPolicy = result ? .allow : .cancel
}
self.injectJavaScriptInterface()
decisionHandler(actionPolicy)
}
}

Expand Down

0 comments on commit b730cbc

Please sign in to comment.