@capgo/capacitor-native-market 8.0.42 → 8.0.44

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.
@@ -25,7 +25,7 @@ struct APIResult: Codable {
25
25
  */
26
26
  @objc(NativeMarket)
27
27
  public class NativeMarket: CAPPlugin, CAPBridgedPlugin {
28
- private let pluginVersion: String = "8.0.42"
28
+ private let pluginVersion: String = "8.0.44"
29
29
  public let identifier = "NativeMarketPlugin"
30
30
  public let jsName = "NativeMarket"
31
31
  public let pluginMethods: [CAPPluginMethod] = [
@@ -87,19 +87,25 @@ public class NativeMarket: CAPPlugin, CAPBridgedPlugin {
87
87
  }
88
88
 
89
89
  @objc func search(_ call: CAPPluginCall) {
90
- if call.hasOption("terms") {
91
- let terms = call.getString("terms")
90
+ guard let terms = call.getString("terms") else {
91
+ call.reject("terms is missing")
92
+ return
93
+ }
92
94
 
93
- let url = "itms-apps://itunes.apple.com/search?term=" + terms!
94
- let appUrl = URL(string: url)
95
+ var components = URLComponents()
96
+ components.scheme = "itms-apps"
97
+ components.host = "itunes.apple.com"
98
+ components.path = "/search"
99
+ components.queryItems = [URLQueryItem(name: "term", value: terms)]
100
+ guard let appUrl = components.url else {
101
+ call.reject("Invalid search URL")
102
+ return
103
+ }
95
104
 
96
- if UIApplication.shared.canOpenURL(appUrl!) {
97
- UIApplication.shared.open(appUrl!, options: [:]) { (_) in
98
- call.resolve()
99
- }
105
+ if UIApplication.shared.canOpenURL(appUrl) {
106
+ UIApplication.shared.open(appUrl, options: [:]) { (_) in
107
+ call.resolve()
100
108
  }
101
- } else {
102
- call.reject("terms is missing")
103
109
  }
104
110
  }
105
111
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/capacitor-native-market",
3
- "version": "8.0.42",
3
+ "version": "8.0.44",
4
4
  "description": "A native market plugin for linking to google play or app store.",
5
5
  "module": "dist/esm/index.js",
6
6
  "main": "dist/plugin.cjs.js",