NativeScript / nativescript-app-sync

♻️ Update your app without going through the app store!
MIT License
125 stars 24 forks source link

Android: Update not pushing to production #37

Closed razorsyntax closed 4 years ago

razorsyntax commented 5 years ago

The code is live in the play store.

What's odd is that if I install the same apk to the emulator on the local dev environment that also gets pushed live, the emulator gets the updates and the devices with the same code from the play store do not.

I feel like I'm missing something somewhere but I'm not sure of the issue.

I thought maybe my versioning scheme for android:versionName could be the issue so I changed it from 9 to 9.0 as you can see in the manifest below.

The deployment history shows that the code is being pushed somewhere but no active installs.

Android Manifest:

<manifest
        android:versionCode="18" 
        android:versionName="9.0"
...

main.ts

import { platformNativeScriptDynamic } from 'nativescript-angular/platform';
import { AppModule } from './app.module';
import * as application from 'tns-core-modules/application';
import { AppSyncService } from './services/app-sync.service';

const appSyncService: AppSyncService = new AppSyncService;

platformNativeScriptDynamic().bootstrapModule(AppModule);

application.on(application.resumeEvent, () => {
    // Check for updates when the app is loaded or resumed
    appSyncService.syncWithAppSyncServer();
});

Custom App Sync Service

export class AppSyncService {

    private static APPSYNC_IOS_PRODUCTION_KEY = 'production_key_ios';

    private static APPSYNC_ANDROID_PRODUCTION_KEY = 'production_key_android';

    syncOptions = {
        deploymentKey: isIOS ? AppSyncService.APPSYNC_IOS_PRODUCTION_KEY : AppSyncService.APPSYNC_ANDROID_PRODUCTION_KEY,
        installMode: InstallMode.ON_NEXT_RESTART, // default InstallMode.ON_NEXT_RESTART
        mandatoryInstallMode: isIOS ? InstallMode.ON_NEXT_RESUME : InstallMode.IMMEDIATE, // default InstallMode.ON_NEXT_RESUME
        updateDialog: { // only used for InstallMode.IMMEDIATE
            optionalUpdateMessage: localize('@@AppSync_OptionalUpdateMessage'),
            updateTitle: localize('@@AppSync_UpdateTitle'),
            mandatoryUpdateMessage: localize('@@AppSync_MandatoryUpdateMessage'),
            optionalIgnoreButtonLabel: localize('@@AppSync_OptionalIgnoreButtonLabel'),
            mandatoryContinueButtonLabel: isIOS ? localize('@@AppSync_MandatoryContinueButtonLabel_iOS') : localize('@@AppSync_MandatoryContinueButtonLabel_Android'),
            appendReleaseDescription: true // appends the description you (optionally) provided when releasing a new version to AppSync
        }
    }

    constructor() { }

    syncWithAppSyncServer(): void {
        console.log("Querying AppSync...");
        AppSync.sync(this.syncOptions, (syncStatus: SyncStatus): void => {
            if (syncStatus === SyncStatus.UP_TO_DATE) {
                console.log("AppSync: up to date.");
            } else if (syncStatus === SyncStatus.UPDATE_INSTALLED) {
                console.log("AppSync: update installed.");
            }
        });
    }
}
shiv19 commented 5 years ago

Are you targeting the version number that is live on playstore? And the version name should ideally use semver major.minor.patch 9.0.0

razorsyntax commented 4 years ago

Here's what it looks like on the dev console:

Screen Shot 2019-09-05 at 9 30 27 AM

I'm testing with semver at the moment by pushing a new semver up to the store to see what happens. Will appsync work even if it has a versionName as something like 9.0?

EddyVerbruggen commented 4 years ago

@razorsyntax AppSync looks at the version in your App_Resources/Android/path/AndroidManifest.xml file. So if you don't pass the --targetBinaryVersion <version to patch> flag it will target the one in the manifest (for Android). More in the README.

razorsyntax commented 4 years ago

Thanks guys. I'm assuming my versioning is weird and will concentrate my efforts there. Thanks for all your help!