Приложение codepush update неверно.Это всегда так же, как текущая версия приложения - PullRequest
0 голосов
/ 07 октября 2018

Я пытаюсь заставить работать codepush для моего приложения на Android, которое реагирует на реакцию.Для лучшего понимания и контроля я вручную проверяю наличие обновлений.Вот мой код:

// Check for Codepush app update every time app is opened.
console.log('Checking for codepush update !');
codePush.checkForUpdate(CODEPUSH_DEPLOYMENT_KEY, (update) => {console.log('handleBinaryVersionMismatchCallback: ', update)})
    .then((update) => {
        console.log('Code push remote package: ', update);
        if (update != null) {
            let desc = update['description'];
            let newVersion = update['appVersion'];
            let currentVersion = RNDeviceInfo.getVersion();
            console.log('current version: ', currentVersion);

            let currentSemVer = currentVersion.split('.');
            let newSemVersion = newVersion.split('.');
            let curV = parseFloat(currentSemVer[1] + '.' + currentSemVer[2]);
            let newV = parseFloat(newSemVersion[1] + '.' + newSemVersion[2]);
            console.log('currentSemVer:', currentSemVer);
            console.log('newSemVersion:', newSemVersion);
            console.log('curV:', curV);
            console.log('newV:', newV);

            if (currentVersion === newVersion) {
                console.log('Exact same version. Ignoring codepush');
                return;
            }
            if (newSemVersion[0] !== currentSemVer[0]) {
                console.log('Major version mismatch. Ignoring codepush');
                return;
            }
            if (newV < curV) {
                console.log('Older version. Ignoring codepush');
                return;
            }

            codePush.sync({
                updateDialog: true,
                installMode: codePush.InstallMode.IMMEDIATE,
            });
        }
    });

Чтобы выпустить новое обновление, я обновляю файл android / app / build.gradle следующим образом:

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 8
        versionName "2.2.6"

и

appcenter codepush release-react -a <appname> -t ">=2.0.0 <=2.2.9" -d Production --description 'Trying to get codepush working'

В logcat я вижу, что он получает обновление, однако appVersion этого обновления совпадает с приложением, которое было установлено из playstore.Пробовал несколько выпусков на codepush, метка увеличивается, но appVersion этого не делает.

10-07 10:14:51.798 7668-7701/? I/ReactNativeJS: 'Code push remote package: ', { deploymentKey: '<key>',
      description: 'Trying to get codepush working',
      label: 'v8',
      appVersion: '2.2.5',
      isMandatory: false,
      packageHash: '<>',
      packageSize: 616685,
      downloadUrl: '<>',
      download: [Function],
      isPending: false,
      failedInstall: false }
    'current version: ', '2.2.5'
    'currentSemVer:', [ '2', '2', '5' ]
    'newSemVersion:', [ '2', '2', '5' ]
10-07 10:14:51.799 7668-7701/? I/ReactNativeJS: 'curV:', 2.5
    'newV:', 2.5
    Exact same version. Ignoring codepush

Неправильно ли я понимаю, что appVersion должна быть версией приложения обновления из файла build.gradle?

...