Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capacitor support #25

Closed
jjacobs33589 opened this issue Jul 10, 2021 · 3 comments
Closed

Capacitor support #25

jjacobs33589 opened this issue Jul 10, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@jjacobs33589
Copy link

I've been using this plugin for my cordova app for a few months and it's been working great!

I'm in the process of converting from cordova to capacitor and am wondering if I can still use this?

@kolbasa
Copy link
Owner

kolbasa commented Jul 12, 2021

Unfortunately, I have not yet had time to check what is needed for Capacitor.

However, according to the documentation, Cordova plugins can also be used with Capacitor without any problems.
https://capacitorjs.com/docs/v2/cordova/using-cordova-plugins

A warning beforehand: I have rewritten the complete plugin the last few days.
A lot has changed. A preview can be found here: EDIT: It is now released

v2.0.0:
https://github.com/kolbasa/cordova-plugin-apkupdater/tree/refactoring

Demo-Apk:
https://github.com/kolbasa/cordova-plugin-apkupdater-demo

I am almost finished with the changes.

Then I want to write at least a detailed tutorial how to use the plugin with Ionic > 2 / Capacitor.
I'm on it, but right now I can't tell you how to configure it there.

@kolbasa
Copy link
Owner

kolbasa commented Jul 14, 2021

I have tried a bit with the latest Ionic version. Here is my first successful attempt. Of course, I have to say that I'm not really familiar with the new Ionic versions. But maybe it already helps.

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

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

export class HomePage {

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

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

  async downloadAndInstall() {
    const apkUpdater = (window as any).ApkUpdater;

    const response = await this.httpClient.get<any>(this.endpoint + '/manifest.json').toPromise();

    const remoteVersion = response.version;
    const installedVersion = (await apkUpdater.getInstalledVersion()).version.name;

    if (remoteVersion > installedVersion) {
      await apkUpdater.download(this.endpoint + '/update.zip', {password: 'aDzEsCceP3BPO5jy', onDownloadProgress: console.log});
      await apkUpdater.install();
    }
  }

}

@kolbasa kolbasa added the enhancement New feature or request label Jul 17, 2021
@kolbasa
Copy link
Owner

kolbasa commented Jul 18, 2021

I have now tried Capacitor and implemented a TypeScript Api on Plugin-Version: 2.2.0.

Installation:

npm install cordova-plugin-apkupdater

Sample Implementation:
https://github.com/kolbasa/cordova-plugin-apkupdater/wiki/Sample-Implementation

If you have problems with it, feel free to reopen the issue.

@kolbasa kolbasa closed this as completed Jul 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants