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

@aurora-org/react-native-xupdate-typescript

v1.1.0

Published

A React-Native plugin for XUpdate(Android Version Update Library).

Downloads

9

Readme

react-native-xupdate

Version Issue Star

A React-Native plugin for XUpdate(Android Version Update Library).

Getting started

$ npm install @aurora-org/react-native-xupdate-typescript --save

Mostly automatic installation

React Native after 0.60 will autolinked modules.

$ react-native link @aurora-org/react-native-xupdate-typescript

Manual installation

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.xuexiang.xupdate.RNXUpdatePackage; to the imports at the top of the file

2. Append the following lines to android/settings.gradle:

include ':@aurora-org/react-native-xupdate-typescript'
project(':@aurora-org/react-native-xupdate-typescript').projectDir = new File(rootProject.projectDir, 	'../node_modules/@aurora-org/react-native-xupdate-typescript/android')

3. Insert the following lines inside the dependencies block in android/app/build.gradle:

compile project(':@aurora-org/react-native-xupdate-typescript')

Usage

Only use for Android.

Initialization

import {XUpdate} from '@aurora-org/react-native-xupdate-typescript';

//Initialization
initXUpdate() {
    let args = new InitArgs();
    args.debug = true;
    args.isPostJson = false; // post json
    args.isWifiOnly = false;
    args.isAutoMode = false;
    args.supportSilentInstall = false; // need root privileges
    args.enableRetry = false;

    //Initialize SDK
    XUpdate.init(args).then(result => {
        this.setState({
            _message: 'Initialize success:' + JSON.stringify(result),
        });
    }).catch(error => {
        console.log(error);
        this.setState({
            _message: 'Initialize failed:' + error,
        });
    });

    XUpdate.setCustomParser({parseJson: this.customParser});
    XUpdate.addErrorListener(this.errorListener);
}

JSON Format

{
  "Code": 0, // 0: success, other: failed
  "Msg": "", // error message
  "UpdateStatus": 1, // 0: no update, 1: non-mandatory update, 2: mandatory update
  "VersionCode": 3,
  "VersionName": "1.0.2",
  "ModifyContent": "",
  "DownloadUrl": "",
  "ApkSize": 2048,
  "ApkMd5": "..." // required
}

CheckUpdate

    checkUpdateDefault() {
        let args = new UpdateArgs(_updateUrl);
        XUpdate.update(args);
    }

    checkUpdateSupportBackground() {
        let args = new UpdateArgs(_updateUrl);
        args.supportBackgroundUpdate = true;
        XUpdate.update(args);
    }

    checkUpdateRatio() {
        let args = new UpdateArgs(_updateUrl);
        args.widthRatio = 0.6;
        XUpdate.update(args);
    }

    // mandatory update
    checkUpdateForce() {
        let args = new UpdateArgs(_updateUrl2);
        XUpdate.update(args);
    }

    // need root privileges
    checkUpdateAutoMode() {
        let args = new UpdateArgs(_updateUrl);
        args.isAutoMode = true;
        XUpdate.update(args);
    }

    enableChangeDownLoadType() {
        let args = new UpdateArgs(_updateUrl);
        args.overrideGlobalRetryStrategy = true;
        args.enableRetry = true;
        args.retryContent = 'Switch to another site?';
        args.retryUrl = 'https://example.com/test.apk';
        XUpdate.update(args);
    }

    showRetryDialogTip() {
        XUpdate.showRetryUpdateTip('content', 'url');
    }

Custom JSON Format

1.Setting up a custom update parser

XUpdate.setCustomParser({parseJson: this.customParser})

customParser = (json) => {
  let appInfo = JSON.parse(json)
  return {
    // required
    hasUpdate: appInfo['hasUpdate'],
    versionCode: appInfo['versionCode'],
    versionName: appInfo['versionName'],
    updateContent: appInfo['updateLog'],
    downloadUrl: appInfo['apkUrl'],

    // optional
    isIgnorable: appInfo['isIgnorable'],
    apkSize: appInfo['apkSize'],
  }
}

2.Set the parameter isCustomParse to true

customJsonParse() {
    let args = new UpdateArgs(_updateUrl3);
    args.isCustomParse = true;
    XUpdate.update(args);
}

Update By UpdateEntity Directly

checkUpdateByUpdateEntity() {
    let args = new UpdateArgs();
    args.supportBackgroundUpdate = true;
    XUpdate.updateByInfo(args, {
        // required
        hasUpdate: AppInfo['hasUpdate'],
        versionCode: AppInfo['versionCode'],
        versionName: AppInfo['versionName'],
        updateContent: AppInfo['updateLog'],
        downloadUrl: AppInfo['apkUrl'],

        // optional
        isIgnorable: AppInfo['isIgnorable'],
        apkSize: AppInfo['apkSize'],
    });
}

Custom Update Prompt Style

Currently, only theme color and top picture customization are supported!

1.Configure top picture, Path: android/app/src/main/res/values/drawable

2.Set the parameter themeColor and topImageRes

customPromptDialog() {
    let args = new UpdateArgs(_updateUrl);
    args.themeColor = '#FFFFAC5D';
    args.topImageRes = 'bg_update_top';
    XUpdate.update(args);
}