@parrotnavy/rn-native-updates 0.10.0 → 0.10.1

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.
@@ -14,15 +14,23 @@ public class NativeUpdatesModule: NSObject, RCTBridgeModule {
14
14
  return false
15
15
  }
16
16
 
17
- @objc func constantsToExport() -> [AnyHashable: Any]! {
17
+ @objc public func constantsToExport() -> [AnyHashable: Any]! {
18
18
  return [
19
19
  "currentVersion": Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "0.0.0",
20
20
  "buildNumber": Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "0",
21
21
  "packageName": Bundle.main.bundleIdentifier ?? "",
22
- "country": Locale.current.region?.identifier ?? "US"
22
+ "country": getCountryCode()
23
23
  ]
24
24
  }
25
25
 
26
+ private func getCountryCode() -> String {
27
+ if #available(iOS 16, *) {
28
+ return Locale.current.region?.identifier ?? "US"
29
+ } else {
30
+ return Locale.current.regionCode ?? "US"
31
+ }
32
+ }
33
+
26
34
  @objc func getAppStoreVersion(_ country: String?, forceRefresh: Bool, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
27
35
  Task {
28
36
  do {
@@ -38,7 +46,7 @@ public class NativeUpdatesModule: NSObject, RCTBridgeModule {
38
46
  throw AppStoreError.invalidBundleId
39
47
  }
40
48
 
41
- let countryCode = country ?? Locale.current.region?.identifier ?? "US"
49
+ let countryCode = country ?? getCountryCode()
42
50
  let timestamp = Int(Date().timeIntervalSince1970)
43
51
  let urlString = "https://itunes.apple.com/lookup?bundleId=\(bundleId)&country=\(countryCode)&date=\(timestamp)"
44
52
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parrotnavy/rn-native-updates",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "React Native app update checker with hooks support. Uses Play Core for Android and iTunes Lookup API for iOS.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",