├── .github
└── workflows
│ ├── push.yml
│ └── test.yml
├── .gitignore
├── .npmignore
├── .prettierrc
├── LICENSE
├── README.md
├── babel.config.js
├── index.d.ts
├── index.js
├── package.json
├── src
├── providers
│ ├── android.js
│ └── ios.js
├── utils.js
└── versions.js
├── tests
├── index.test.js
└── version.test.js
└── yarn.lock
/.github/workflows/push.yml:
--------------------------------------------------------------------------------
1 | name: Push
2 | concurrency:
3 | group: push
4 | on:
5 | push:
6 | branches:
7 | - master
8 | jobs:
9 | release:
10 | runs-on: ubuntu-latest
11 | permissions:
12 | contents: write
13 | issues: write
14 | pull-requests: write
15 | id-token: write
16 | steps:
17 | - name: Check out repository code
18 | uses: actions/checkout@v4
19 | with:
20 | persist-credentials: false
21 |
22 | - name: Setup node
23 | uses: actions/setup-node@v4
24 | with:
25 | node-version: 20
26 | cache: yarn
27 |
28 | - name: Install dependencies
29 | run: yarn --frozen-lockfile
30 |
31 | - name: Test
32 | run: yarn test
33 |
34 | - name: Install latest npm
35 | run: npm install -g npm@latest
36 |
37 | - name: Release
38 | env:
39 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
40 | NPM_TOKEN: ${{secrets.NPM_TOKEN}}
41 | NPM_CONFIG_PROVENANCE: true
42 | run: yarn release
43 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: Tests
2 | on: [ push ]
3 | jobs:
4 | Jest:
5 | runs-on: ubuntu-latest
6 | steps:
7 | - name: Check out code
8 | uses: actions/checkout@v4
9 | - name: Setup node
10 | uses: actions/setup-node@v4
11 | with:
12 | node-version: 20
13 | - name: Install dependencies
14 | run: yarn
15 | - name: Run tests
16 | run: yarn test
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | *.log
3 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | example
2 | backend
3 | tests
4 | babel.config.js
5 | .github
6 | .idea
7 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {}
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Flexible Agency
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # React Native Check Version
2 |
3 | [](https://npmjs.com/package/react-native-check-version)
4 | [](https://github.com/includable/react-native-check-version/blob/master/LICENSE)
5 |
6 | ---
7 |
8 | An easy way to check if there's an update available for the current app in the App Store or Google Play.
9 |
10 | Note that you need [react-native-device-info](https://github.com/rebeccahughes/react-native-device-info) to be
11 | installed for this library to function as expected, or you need to manually supply the `bundleId` and
12 | `currentVersion` values in the options object.
13 |
14 | ## Installation
15 |
16 | ```
17 | yarn add react-native-check-version react-native-device-info
18 | ```
19 |
20 | ## Basic usage
21 |
22 | Use the `checkVersion` method to get information:
23 |
24 | ```js
25 | import { checkVersion } from "react-native-check-version";
26 |
27 | const version = await checkVersion();
28 | console.log("Got version info:", version);
29 |
30 | if (version.needsUpdate) {
31 | console.log(`App has a ${version.updateType} update pending.`);
32 | }
33 | ```
34 |
35 | ## API
36 |
37 | ### Function usage
38 |
39 | `checkVersion()` accepts an _optional_ options object, which may contain the following keys:
40 |
41 | - string `platform`: platform to check for, defaults to React Native's `Platform.OS`
42 | - string `country`: App Store specific country, defaults to `us`
43 | - string `bundleId`: bundle identifier to check, defaults to the value retrieved using react-native-device-info
44 | - string `currentVersion`: version to check against, defaults to the currently installed version
45 |
46 | ### Response object
47 |
48 | `checkVersion()` returns a Promise, which when resolved will return an object with the following properties:
49 |
50 | - string `version`: latest version number of the app
51 | - string `released`: (iOS only) ISO 8601 release date of that version
52 | - string `url`: download URL for the latest version
53 | - string `notes`: release notes of latest version
54 | - boolean `needsUpdate`: whether the latest version number is higher than the currently installed one
55 | - string `updateType`: `major`, `minor` or `patch`, based on how big the difference is between the currently installed
56 | version and the available version
57 |
58 | ## Changelog
59 |
60 | - `v1.1.0`: Use built-in `fetch` rather than Axios library.
61 | - `v1.0.18`: Update headers for Google Play HTTP request.
62 | - `v1.0.14`: Updated Android logic to use new Google Play endpoints.
63 | - `v1.0.13`: Added a try-catch within the main `checkVersion` function to prevent error responses from the HTTP requests
64 | to throw errors.
65 | - `v1.0.12`: Replaced the [custom backend](https://github.com/flexible-agency/react-native-check-version/issues/30) used
66 | previously by doing calls directly within the app. Please note Google Play has updated their web pages, making older
67 | versions not functional.
68 |
69 | ## Authors
70 |
71 | This library is developed by Includable, a creative app development agency.
72 |
73 | - Thomas Schoffelen
74 |
75 |
76 |
77 | ---
78 |
79 |