npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-check-version

v1.3.0

Published

Check if the user is running the latest version of the app

Downloads

68,391

Readme

React Native Check Version

NPM GitHub license


An easy way to check if there's an update available for the current app in the App Store or Google Play.

Note that you need react-native-device-info to be installed for this library to function as expected, or you need to manually supply the bundleId and currentVersion values in the options object.

Installation

yarn add react-native-check-version react-native-device-info

Basic usage

Use the checkVersion method to get information:

import { checkVersion } from "react-native-check-version";

const version = await checkVersion();
console.log("Got version info:", version);

if (version.needsUpdate) {
   console.log(`App has a ${version.updateType} update pending.`);
}

API

Function usage

checkVersion() accepts an optional options object, which may contain the following keys:

  • string platform: platform to check for, defaults to React Native's Platform.OS
  • string country: App Store specific country, defaults to us
  • string bundleId: bundle identifier to check, defaults to the value retrieved using react-native-device-info
  • string currentVersion: version to check against, defaults to the currently installed version

Response object

checkVersion() returns a Promise, which when resolved will return an object with the following properties:

  • string version: latest version number of the app
  • string released: (iOS only) ISO 8601 release date of that version
  • string url: download URL for the latest version
  • string notes: release notes of latest version
  • boolean needsUpdate: whether the latest version number is higher than the currently installed one
  • string updateType: major, minor or patch, based on how big the difference is between the currently installed version and the available version

Changelog

  • v1.1.0: Use built-in fetch rather than Axios library.
  • v1.0.18: Update headers for Google Play HTTP request.
  • v1.0.14: Updated Android logic to use new Google Play endpoints.
  • v1.0.13: Added a try-catch within the main checkVersion function to prevent error responses from the HTTP requests to throw errors.
  • v1.0.12: Replaced the custom backend used previously by doing calls directly within the app. Please note Google Play has updated their web pages, making older versions not functional.

Authors

This library is developed by Flexible Agency, a creative app development agency.