GithubHelp home page GithubHelp logo

corgiyun / react-native-app-upgrade Goto Github PK

View Code? Open in Web Editor NEW

This project forked from songxiaoliang/react-native-app-upgrade

0.0 0.0 0.0 390 KB

react native 版本升级

Home Page: https://www.npmjs.com/package/rn-app-upgrade

JavaScript 9.58% Objective-C 11.00% Java 79.43%

react-native-app-upgrade's Introduction

React Native App 版本升级封装库,兼容Android4以上所有版本

⚠️ 如遇到lStar编译失败问题,请将build & target version 改成 31

一、功能

Android

(1)版本检测
(2)下载更新
(3)进度提示
(4)自动安装

iOS

(1)版本检测
(2)自动跳转App Store

二、使用

  yarn add rn-app-upgrade

  // or 
  npm install rn-app-upgrade
 
  // less than 0.6
  react-native link rn-app-upgrade

iOS 打开Xcode, 将 ios_upgrade 导入到项目目录。

  import { 
    downloadApk,
    versionName,
    versionCode,
    openAPPStore,
    checkIOSUpdate,
    addDownLoadListener,
  } from 'rn-app-upgrade';
  
  //可通过RN.versionName获取apk版本号和远程版本号进行比较
  if(Android) {
    if(res.versionCode > versionCode) {
        downloadApk({
            interval: 666, // listen to upload progress event, emit every 666ms
            apkUrl: "https://xxxx.apk",
            downloadInstall: true,
            callback: {
                onProgress: (received, total, percent) => {},
                onFailure: (errorMessage, statusCode) => {},
                onComplete: () => {},
            },
        });
    }
  } else {
    const IOSUpdateInfo = await checkIOSUpdate(appid, 当前版本号);
    IOSUpdateInfo.code // -1: 未查询到该App 或 网络错误 1: 有最新版本 0: 没有新版本
    IOSUpdateInfo.msg
    IOSUpdateInfo.version
  }

react-native-app-upgrade's People

Contributors

songxiaoliang avatar puti94 avatar yogaan avatar lf7817 avatar wangyihang875 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.