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

reactnative-forceupdate

v1.0.4

Published

A lightweight React Native package for enforcing app version updates. Ensure users always have the latest enhancements and fixes without dependencies.

Downloads

156

Readme

reactnative-forceupdate

A lightweight React Native package for enforcing app version updates. Ensure users always have the latest enhancements and fixes without dependencies.

CI npm version Coverage Status License Status Issues Status Tag Status Languages Status Repo Size Status

Features

  • Enforce app version updates for Android and iOS
  • Ensure users have the latest enhancements and fixes
  • Lightweight and native implementation
  • No external dependencies
  • 100% test coverage
  • Made with Typescript
  • Customizable forceupdate modal on forceupdate dashboard
  • Callbacks for handling modal events
  • Support for multiple languages
  • Support for multiple platforms
  • A completed SaaS to manage your versions

Creating an account

To use this package, you need to create an account on ForceUpdate and create a project. You will get an API key that you will use to check if the app is updated.

There is a free plan that you can use to test the package!

Installation

Install the package using:

npm

npm install reactnative-forceupdate

or

yarn

yarn add reactnative-forceupdate

Usage

Import the package

import { ForceUpdate } from 'reactnative-forceupdate';

Wrap your app with the ForceUpdate component. It will check if the app is updated and show a modal if it's not.

<ForceUpdate
  api_key="6bbc51d23e5938d512a62a83c230dfdef89ab7a2c75bdc1f0f42909d5e04feb5"
  language={'en'}
  platform={'ANDROID'}
  version={'1.0.2'}
>
  <View>
    <FakeProvider>
      <Text>My App</Text>
    </FakeProvider>
  </View>
</ForceUpdate>

API Reference

These properties are required when instantiating the ForceUpdate component.

| Parameter | Explanation | | --------- | ------------------------------------------------------------------------------- | | Platform | It should be either 'ANDROID' or 'IOS' | | Version | The actual version of your app | | Api_key | The API key of your project. You can get it on your forceupdate.app dashboard | | Language | The language of the message. The same defined on your forceupdate.app dashboard |

Optional props (Customization)

These are the optional props that you can use to customize the modal.

| Parameter | Explanation | Context | Default value | | ----------------- | ---------------------------------------------------- | ------------- | ------------- | | showAppBackground | Show the app background behind the forceupdate modal | true or false | true |

Optional props (Callbacks)

These are the optional props that you can use to handle the modal events.

| Parameter | Explanation | Context | | ---------------------- | -------------------------------------------------- | -------------------------------------------------------------------------- | | onDismiss | Callback when the user dismisses the modal | only appliable when force_update is false | | onForceUpdate | Callback when the user clicks on the update button | only appliable when force_update is true | | onUpdate | Callback when the user clicks on the update button | only appliable when force_update is false and needs_update is true | | onVersionCheck | Callback when the version check starts | always | | onVersionCheckError | Callback when the version check fails | always when error | | onVersionCheckSuccess | Callback when the version check succeeds | always when success | | onVersionCheckStart | Callback when the version check starts | always | | onVersionCheckEnd | Callback when the version check ends | always | | onVersionCheckComplete | Callback when the version check completes | always | | onLoadingStart | Callback when the loading starts | always | | onLoadingEnd | Callback when the loading ends | always |

API response

You do not manipulate the API response, but it's important to understand the properties that you can use to customize the modal on forceupdate.app dashboard.

| Parameter | Explanation | Context | | ------------------- | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | needs_update | If the app needs an update | Defined on your version on forceupdate.app | | force_update | If the app needs a force update | Defined on your version on forceupdate.app | | title | The title of the modal | The title that will be shown to the user when modal appear | | message | The message that will be shown to the user | The message that will be shown to the user when modal appear | | store_url | The url of the app store | The url that the user will be redirected when clicking on the update button. It consider the platform that the user is using, this property is defined on when you call <ForceUpdate ... platform={'ANDROID'} /> | | dismiss_button_text | The text of the dismiss button | The text of the dismiss button, defined on your version on forceupdate.app | | update_button_text | The text of the update button | The text of the update button, defined on your version on forceupdate.app |

Examples

Expo

import Constants from 'expo-constants';
import { Platform } from 'react-native';

// ...

const version = Constants.manifest.version;
const platform = Platform.OS === 'ios' ? 'IOS' : 'ANDROID';
const language = 'en'; // or get it from any library like I18n
const apiKey =
  '6bbc51d23e5938d512a62a83c230dfdef89ab7a2c75bdc1f0f42909d5e04feb5';

return (
  <ForceUpdate
    api_key={apiKey}
    language={language}
    platform={platform}
    version={version}
  >
    <YourApp />
  </ForceUpdate>
);

React Native

If you are using react-native without expo, you can get the version using the react-native-device-info package.

import DeviceInfo from 'react-native-device-info';

And then use it like this:

import { Platform } from 'react-native';
// ...
const version = DeviceInfo.getVersion();
const language = 'en'; // or get it from any library like I18n
const platform = Platform.OS === 'ios' ? 'IOS' : 'ANDROID';
const apiKey =
  'd723422430af5a6081a95be021dc7437bb5c74ec0648ef818e4d148f928e7043';

return (
  <ForceUpdate
    api_key={apiKey}
    language={language}
    platform={platform}
    version={version}
  >
    <YourApp />
  </ForceUpdate>
);

Api key

The API key is a unique identifier for your app. You can get it by creating an account on ForceUpdate and create a project to get one.


Made with create-react-native-library