1.0.8 • Published 3 years ago

@iwubida/react-native-update-version v1.0.8

Weekly downloads
30
License
MIT
Repository
github
Last release
3 years ago

@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}
  />
);

参数支持说明

NameTypeDefaultDescription
versionstring1最新的内部版本号
versionCodestring'v1.0.0'最新的外部版本号
updateInfostring''升级内容信息 '1、支持第三方平台业务|2、展示第三方平台订单取单编码'
promotenumber0更新方式(1升级,0不升级,2强制升级)
clientUrlstring''安卓下载地址
appleIdstring''必填 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');
}
1.0.8

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago