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

@iwubida/react-native-update-version

v1.0.8

Published

react-native Update Version

Downloads

176

Readme

@iwubida/react-native-update-version

支持App版本自动升级提醒和升级,提供可选的升级页面组件,同时支持Android和iOS。

npm version

例子:传入最新的内部版本号外部版本号后该插件可以自动检测出该App是否需要弹出更新提示。

  • 可以选择使用该插件自带的样式组件(支持Android和iOS)
  • Android点击立即升级后,开始下载过程
  • iOS点击立即升级后,跳转App Store

安装

yarn

yarn add @iwubida/react-native-update-version

npm install

npm install @iwubida/react-native-update-version --save

项目配置

自动配置(推荐)

react-native link react-native-version-number
react-native link @iwubida/react-native-update-version

使用

使用提供的升级页面组件

import UpdateVersion from '@iwubida/react-native-update-version';

const Demo = ({appleId, version, versionCode, promote, clientUrl, updateInfo}) => (
  <UpdateVersion
    appleId={appleId}
    version={version}
    versionCode={versionCode}
    promote={promote}
    clientUrl={clientUrl}
    updateInfo={updateInfo}
  />
);

参数支持说明

| Name | Type | Default | Description | | :-: | :-: | :-: | :-: | | version | string | 1 | 最新的内部版本号 | | versionCode | string | 'v1.0.0' | 最新的外部版本号 | | updateInfo | string | '' | 升级内容信息 '1、支持第三方平台业务|2、展示第三方平台订单取单编码' | | promote | number | 0 | 更新方式(1升级,0不升级,2强制升级) | | clientUrl | string | '' | 安卓下载地址 | | appleId | string | '' | 必填 appleId |

不使用提供的升级页面组件,要自己写页面组件的,👇下面方法可提供下载过程。

import { NativeModules } from 'react-native';
const { RNUpdateVersionModule } = NativeModules;

iOS

// Go to appStore
RNUpdateVersionModule.update(`${appleId}`);

Android

// Download apk
RNUpdateVersionModule.update(`${apkUrl}`);
// Download Progress
DeviceEventEmitter.addListener('DownloadApkProgress', arg => {
  if (arg.error) {
    console.log('下载失败');
  } else if (arg.done) {
    console.log('升级成功');
  } else {
    const {percent} = arg;
    console.log(`${percent}%`);
  }
})

componentWillUnmount() {
  // RemoveListener
  DeviceEventEmitter.removeListener('DownloadApkProgress');
}