React-native-upgrade-android

Source: Internet
Author: User

React Native Version Upgrade plugin (Android only), react-native version requires 0.17.0 and above

How to install 1. Install the NPM package first
NPM Install react-native-upgrade-android--save
2.link Auto Link Method ~ NPM requires node version 4.1 or higher
NPM Link

Link Success Command line prompt

NPM info linking react-native-upgrade-android Android dependency
Manual link~ (if Auto link is not possible)

# # # #Android

// file: android/settings.gradle...include ‘:react-native-upgrade-android‘project(‘:react-native-upgrade-android‘).projectDir = new File(settingsDir, ‘../node_modules/react-native-upgrade-android/android‘)
// file: android/app/build.gradle...dependencies {    ...    compile project(‘:react-native-upgrade-android‘)}

android/app/src/main/java/<你的包名>/MainActivity.java, public class MainActivity previously added:

Com.lenny.modules.upgrade.UpgradeModule;

If react-native-is .addPackage(new MainReactPackage()) added after version <0.18.0:

. Addpackage (upgradpackage ())

If react-native-version >=0.18.0 is new MainReactPackage() added later

,upgradepackage ()
How to use the ingest package
import Upgrade from ‘react-native-upgrade-android‘;
Apiupgrade.init ()
Must be initialized before use

Similar to the following:

Componentdidmount () {  const {    isSet, this  .  if (Platform.') iOSUpgrade.  Init (); }}
Weiboapi.startdownload (DownloadURL, version, FileName)

Start download

Parameter information  downloadurl: Download apk address (absolute address)string  version: The version number to download (prevents duplicate downloads)string fileName 
Add Listener

Similar to the following:

Componentdidmount () {const {IsSet,}=This.Propsif (Platform.OS!==' iOS‘) {Upgrade.Init ();Deviceeventemitter.AddListener (' Progress‘, (E= = {if (E.Code===' 0000‘) {Start downloadThis.SetState ({isloading:True,}); }Elseif (E.Code===' 0001') { //download, update progress bar this .  SetState ({fileSize: E.fileSize, downsize: E.downsize,}); Else if (E.code = = = ' 0002') { //download complete this .  SetState ({fileSize: E.fileSize, downsize: E.downsize,});}});    }}  

GitHub Address: Https://github.com/lennyup/react-native-upgrade-android

React-native-upgrade-android

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.