3.0.1 • Published 1 year ago

@heytea/react-native-heytea-codepush v3.0.1

Weekly downloads
5
License
MIT
Repository
github
Last release
1 year ago

@heytea/react-native-heytea-codepush

GitHub license npm

Getting started

$ npm install @heytea/react-native-heytea-codepush --save

Mostly automatic installation

$ react-native link @heytea/react-native-heytea-codepush

Usage

ReactNative

import ReactNativeHeyteaCodePush from 'react-native-heytea-codepush';

/**
 * 运行bundle过程中错误,调用该函数,用于判断热更新的成功、失败,以判断是否回滚操作
 * 目前只支持安卓
 */
ReactNativeHeyteaCodePush.loadFail(): void;

/**
 * 检查是否需要热更新
 * @param versionCode 热更新文件的versionCode
 */
ReactNativeHeyteaCodePush.checkForHotUpdate(versionCode: number): Promise<boolean>;

/**
 * 检查是否需要App更新
 * @param versionCode App的versionCode, iOS对应versionNumber
 */
ReactNativeHeyteaCodePush.checkForAppUpdate(versionCode: number): Promise<boolean>;

/**
 * 同步热更新,与微软CodePush基本一致
 */
ReactNativeHeyteaCodePush.syncHot(
    restartAfterUpdate: boolean,
    md5: string,
    versionCode: number,
    url: string,
    callback: (success?: boolean, error?: string) => void
): void;

/**
 * 同步安卓App更新,下载apk并提示安装
 */
ReactNativeHeyteaCodePush.syncAndroidApp(
    md5: string,
    versionCode: number,
    url: string,
    callback: (success?: boolean, error?: string) => void
): void;

/**
 * 同步iOS App更新,跳转App store
 * @param {string} url App Store应用链接
 */
ReactNativeHeyteaCodePush.synciOSApp(url: string): void;

/**
 * 监听下载进度
 */
componentDidMount() {
  this.progressEmitter = eventEmitter.addListener('syncProgress', (progress: number) => {

  })
}

componentWillMount() {
  this.progressEmitter && this.progressEmitter.remove()
}

Android

public class MainApplication extends Application implements ReactApplication {
    private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
        ...
        // 2. Override the getJSBundleFile method in order to let
        // the CodePush runtime determine where to get the JS
        // bundle location from on each app start
        @Override
        protected String getJSBundleFile() {
            return HeyteaCodePush.getJSBundleFile(MainApplication.this);
        }
    };
}

iOS

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
  #if DEBUG
    return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  #else
    return [HeyteaCodePush bundleURL];
  #endif
}
3.0.1

1 year ago

2.9.9

2 years ago

3.0.0

2 years ago

1.2.99

2 years ago

2.2.5

2 years ago

2.2.4

2 years ago

2.2.1

2 years ago

2.2.3

2 years ago

2.2.2

2 years ago

2.2.0

2 years ago

2.1.1

3 years ago

2.0.2

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago