Skip to content

Commit a8646d4

Browse files
committed
feat: add countryCode option to VersionCheck for region-specific updates
- Introduced a new `countryCode` parameter in the `needsUpdate`. - Updated documentation to reflect the new option and its usage.
1 parent 75075a3 commit a8646d4

File tree

6 files changed

+35
-13
lines changed

6 files changed

+35
-13
lines changed

docs/docs/api-reference.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,19 @@ if (await VersionCheck.needsUpdate()) {
8585
if (await VersionCheck.needsUpdate({ level: 'major' })) {
8686
// ...
8787
}
88+
89+
// Check against a specific App Store region
90+
if (await VersionCheck.needsUpdate({ countryCode: 'US' })) {
91+
// ...
92+
}
8893
```
8994

9095
#### Options
9196

9297
| Option | Type | Default | Description |
9398
|--------|------|---------|-------------|
9499
| `level` | `"major" \| "minor" \| "patch"` | `"patch"` | Minimum version bump to trigger `true` |
100+
| `countryCode` | `string` | device country | 2-letter ISO country code (iOS only, ignored on Android) |
95101

96102
- `"major"` — only returns `true` for major bumps (1.x → 2.x)
97103
- `"minor"` — returns `true` for major or minor bumps

docs/docs/compatibility.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@ This page documents the compatibility between different versions of `react-nativ
1818

1919
**Version 2.x and newer is fully built around Nitro 0.35+ support.** All v1.x versions work with Nitro 0.32.0 - 0.34.x.
2020

21-
### Nitro 0.35.0 Improvements
22-
23-
Nitro 0.35.0 includes critical improvements and a memory leak fix in Kotlin HybridObjects. This required changes to:
24-
25-
- **Kotlin**: Regenerated specs with updated JNI initialization
26-
- **Swift & C++**: Specs regenerated for compatibility
27-
28-
Version 2.x and newer leverage these improvements for better performance and stability.
2921

3022
### Upgrading from v1.x to v2.0.0+
3123

docs/docs/usage-examples.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ const hasMinorUpdate = await VersionCheck.needsUpdate({ level: 'minor' })
6767

6868
// Returns true for any version increase (default)
6969
const hasAnyUpdate = await VersionCheck.needsUpdate({ level: 'patch' })
70+
71+
// Check against a specific App Store region (iOS only)
72+
const needsUpdateUS = await VersionCheck.needsUpdate({ countryCode: 'US' })
7073
```
7174

7275
## Detect Install Source

package/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@
8989
"npm": {
9090
"publish": true,
9191
"skipChecks": true,
92-
"publishArgs": [
93-
"--provenance --access public"
94-
]
92+
"publishArgs": ["--provenance --access public"]
9593
},
9694
"github": {
9795
"release": true

package/src/__tests__/index.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,20 @@ describe("VersionCheck API", () => {
105105
}
106106
});
107107

108+
it("should accept options with countryCode parameter", async () => {
109+
const result = VersionCheck.needsUpdate({ countryCode: "US" });
110+
expect(result).toBeInstanceOf(Promise);
111+
const resolved = await result;
112+
expect(typeof resolved).toBe("boolean");
113+
});
114+
115+
it("should accept both level and countryCode options together", async () => {
116+
const result = VersionCheck.needsUpdate({ level: "major", countryCode: "GB" });
117+
expect(result).toBeInstanceOf(Promise);
118+
const resolved = await result;
119+
expect(typeof resolved).toBe("boolean");
120+
});
121+
108122
it("should default to patch level when no options provided", async () => {
109123
const result = await VersionCheck.needsUpdate();
110124
expect(typeof result).toBe("boolean");

package/src/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ export const VersionCheck = {
143143
* - `"minor"` — returns `true` for major or minor bumps
144144
* - `"patch"` — returns `true` for any version increase (default)
145145
*
146+
* @param options - Optional configuration
147+
* @param options.level - Update granularity to check for. Defaults to `"patch"`.
148+
* @param options.countryCode - 2-letter ISO country code (e.g., "US", "GB")
149+
* Defaults to the device's current country from `getCountry()`.
150+
* Only used on iOS; ignored on Android.
151+
*
146152
* @example
147153
* ```ts
148154
* if (await VersionCheck.needsUpdate()) {
@@ -152,10 +158,13 @@ export const VersionCheck = {
152158
*
153159
* // Only prompt for major updates
154160
* const majorUpdate = await VersionCheck.needsUpdate({ level: "major" });
161+
*
162+
* // Check against a specific App Store region
163+
* const needsUpdateUS = await VersionCheck.needsUpdate({ countryCode: "US" });
155164
* ```
156165
*/
157-
needsUpdate: async (options?: { level?: UpdateLevel }): Promise<boolean> => {
158-
const latest = await HybridVersionCheck.getLatestVersion();
166+
needsUpdate: async (options?: { level?: UpdateLevel; countryCode?: string }): Promise<boolean> => {
167+
const latest = await HybridVersionCheck.getLatestVersion(options?.countryCode);
159168
return isNewerVersion(version, latest, options?.level ?? "patch");
160169
},
161170
/**

0 commit comments

Comments
 (0)