kolbasa/cordova-plugin-apkupdater

Cannot update versioning

Closed this issue · 4 comments

I am able to update my Ionic 5 apps using this plugin (kolbasa apk updater), but cannot detect a new version apps available. Please help me... Thank you.

This is the error message:
[ng] Error: src/app/pages/home/home.page.ts:144:46 - error TS2558: Expected 0 type arguments, but got 1.
[ng] 144 const manifest = await this.http.get(this.remote + '/update.json').toPromise();
[ng] ~~~
[ng] Error: src/app/pages/home/home.page.ts:144:81 - error TS2339: Property 'toPromise' does not exist on type 'Promise'.
[ng] 144 const manifest = await this.http.get(this.remote + '/update.json').toPromise();

I'm not quite sure about your error.
Here is a complete working example with an empty Ionic 5 + Angular project. Maybe this already helps you.

src/app/app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';

import { IonicModule, IonicRouteStrategy } from '@ionic/angular';

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';

import { HttpClientModule } from '@angular/common/http';

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule, HttpClientModule],
  providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }],
  bootstrap: [AppComponent],
})
export class AppModule {}

src/app/home/home.page.spec.ts

import {Platform} from '@ionic/angular';
import {Component} from '@angular/core';
import {HttpClient} from '@angular/common/http';

import ApkUpdater, {Update} from 'cordova-plugin-apkupdater';

@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})

export class HomePage {

  remote = 'https://raw.githubusercontent.com/kolbasa/cordova-plugin-apkupdater-demo/master/update';

  constructor(private http: HttpClient, public platform: Platform) {
    platform.ready().then(this.update.bind(this)).catch(console.error);
  }

  async update() {
    const manifest = await this.http.get<Update>(this.remote + '/update.json').toPromise();

    const remoteVersion = manifest.app.version.code;
    const installedVersion = (await ApkUpdater.getInstalledVersion()).version.code;

    if (remoteVersion > installedVersion) {
      await ApkUpdater.download(
        this.remote + '/update.zip',
        {
          zipPassword: 'aDzEsCceP3BPO5jy',
          onDownloadProgress: console.log,
          onUnzipProgress: console.log
        }
      );
      await ApkUpdater.install();
    }
  }

}

Closed. I have improved the versioning section in the readme file.

Can you go to Github for a moment and upload the image there again. It is not displayed.