Coder Social home page Coder Social logo

Comments (38)

aldrigo avatar aldrigo commented on July 27, 2024 1

now it's working as it should! thank you very much, i'll check how I'm going to do the ADB commands in production line and see if it's going to be feasible to do it that way for the new tetens that come out

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

ownerInstall() can be used on any device to which you have physical access.
The setup with adb has to be done only once, after that the app can update itself every time.
This method is perfect for kiosk apps.

from cordova-plugin-apkupdater.

aldrigo avatar aldrigo commented on July 27, 2024

Thank you very much for the feedback, sorry I didn't understand, how to make this ADB setup?

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

No problem. I am happy to help.
Have you seen the instructions here?

Steps:

  1. Install your app with the latest plugin version.
  2. Activate the developer mode on the device.
  3. Connect the device to your PC (adb devices should now show your device)
  4. Execute adb shell dpm set-device-owner your.app.id/de.kolbasa.apkupdater.tools.DAReceiver (replace the your.app.id appropriately)
  5. The ownerInstall() method can now update your app.

from cordova-plugin-apkupdater.

aldrigo avatar aldrigo commented on July 27, 2024

tks! I'm going to test at this point, there's only way to do this ADB config via command prompt?

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

The easiest way is via ADB.

As far as I know there are two more ways to unlock the owner permission:

  • The official way is via Google. However, I can't tell you how much effort it takes to whitelist your app.
  • You sign the app with platform keys. You can get these from the device manufacturer.

from cordova-plugin-apkupdater.

aldrigo avatar aldrigo commented on July 27, 2024

I'm having a return after ADB command:Not allowed to set the device owner because there are already some accounts on the device

from cordova-plugin-apkupdater.

aldrigo avatar aldrigo commented on July 27, 2024

I ask about the reasons to grant permission because I have hundreds of TOTENS (kiosk mod) spread across Brazil, I can't go to each one to give permission, all I wanted was to be able to update the totems without user intervention

from cordova-plugin-apkupdater.

aldrigo avatar aldrigo commented on July 27, 2024

I managed to use ownerInstall() on another clean device, my question now is only in relation to the update because I realized that the Application closes and does not open again alone, is that so?

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

there are already some accounts

Ah yes, forgot to say. You have to log out of Google first. It does not work with a linked Google account.

I ask about the reasons to grant permission because I have hundreds of TOTENS

I understand. However, I am not aware of an easier way. Android is quite strict about that.

I realized that the Application closes and does not open again alone

Hmm. Should actually open up again. Here's a video of what it looks like on my app.

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

I may be able to fix the restart thing though. The logic is controlled by the plugin.
Which Android version are you using?

from cordova-plugin-apkupdater.

aldrigo avatar aldrigo commented on July 27, 2024

here it doesn't open again... I'm using android 8.1.0

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

Ok, I'll see if I can reproduce this. Today I don't have time yet, but tomorrow I'll take care of it.

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

I have fixed the bug now:

cordova plugin add https://github.com/kolbasa/cordova-plugin-apkupdater#device-owner-reload

However, it will take a few more days to get that into the main-branch. I want to put some other stuff in the release version.
But you can already use it that way.

from cordova-plugin-apkupdater.

aldrigo avatar aldrigo commented on July 27, 2024

Good Morning! I just did some testing and the problem still persists... my app doesn't open after updating, but it does notify me that it has been updated by adm, android 8.1.0

const apkUpdater = (window as any).ApkUpdater;

await apkUpdater.isDeviceOwner().then(res =>{

  console.log("deu bom")

}).catch(err =>{
console.log("deu ruim")

})// -> true, false

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

Can you please double check that you actually have plugin version 3.0.1 in your app?

from cordova-plugin-apkupdater.

aldrigo avatar aldrigo commented on July 27, 2024

positive
cordova-plugin-apkupdater 3.0.1 "Apk Updater"

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

Ah, I think I know what the problem is. The update, that is the apk you want to update to, must have the new plugin version. The installed app version doesn't matter.
So you have to generate your update with the new plugin version.

from cordova-plugin-apkupdater.

aldrigo avatar aldrigo commented on July 27, 2024

that must be it, this apk is in version 2.0.2 if I'm not mistaken, I thought that only the current apk should have the plugin updated

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

Yeah, it's not going to work that way. Only an apk with the new plugin version will restart itself.

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

I read yesterday that you can also activate the device owner status on devices with the help of an NFC tag. If your devices have NFC.
https://developers.google.com/android/work/play/emm-api/prov-devices#device_owner_provisioning_methods

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

Oh, apparently also with QR codes, if the devices have a camera:

Some devices, such as tablets, don’t support NFC. QR code provisioning is an easy way 
to provision a distributed fleet of devices that don’t support NFC. An IT admin can send 
QR codes to their users to allow user-driven provisioning.

I'll give that a try when I get a chance.

from cordova-plugin-apkupdater.

aldrigo avatar aldrigo commented on July 27, 2024

wow!! QR code would be great, I use tablets without NFC, I don't even know what to search for, if you can, I'm very grateful!

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

So, I have tried it now and I am surprised how well it works.

First define which app should be used as device owner. The required format can be found here.

Here is the example configuration for my demo app:

{
    "android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME": "de.kolbasa.apkupdater.demo/de.kolbasa.apkupdater.tools.DAReceiver",
    "android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM": "24lpCxXMePT5QGa0wHQl8A7jK9j-d23Sq3OXA9_ZgI8",
    "android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION": "https://raw.githubusercontent.com/kolbasa/cordova-plugin-apkupdater-demo/master/Demo.apk"
}
  • You have to replace the app ID de.kolbasa.apkupdater.demo with yours under [...]_ADMIN_COMPONENT_NAME.
  • You need a public URL to your apk under [...]_PACKAGE_DOWNLOAD_LOCATION
  • Then you need to generate the signature checksum like so for [...]_SIGNATURE_CHECKSUM:
keytool -printcert -jarfile Demo.apk | grep "SHA1" | awk '{print $2}' | xxd -r -p | openssl base64 | tr -d '=' | tr -- '+/=' '-_'

(This is the bash command. On Windows it will look a little different.)

Then generate a QR code with this config on any QR generator page, e.g. here: https://zxing.appspot.com/generator/
(Select Text under Contents).

Here is the QR code for my demo app:
ApkUpdaterDemo

With this, you can now set up your devices as follows:

  • You need a clean device. That means you need to reset it.
  • On the welcome screen, you must now tap the "Hello"-text 6 times.
  • You will be prompted to connect the device to the Internet. Do it. (Wifi access data can also be stored in the QR code.)
  • Now it's time to scan the QR code. If everything goes well, the app is now automatically downloaded and activated as a device owner.

You can also try it first with the QR code of my demo. You just have to reset the device afterwards.
Once you have the QR code you can quite easily instruct other people how to set up the device. It's only a few steps.

from cordova-plugin-apkupdater.

aldrigo avatar aldrigo commented on July 27, 2024

I didn't understand very well the part of generating the QR code but tomorrow morning I will try it calmly ...
I'm using ionic v3 + macOS

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

I have updated the command so that it also works under macOS.

from cordova-plugin-apkupdater.

aldrigo avatar aldrigo commented on July 27, 2024

Good Morning! I just didn't understand this part. Then you need to generate the signature checksum for [...]_SIGNATURE_CHECKSUM

from cordova-plugin-apkupdater.

aldrigo avatar aldrigo commented on July 27, 2024

my device can't install the QR code reader I don't know why

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

Is there an error message?
I have successfully tested it with an Android 7 and 10 device.

from cordova-plugin-apkupdater.

aldrigo avatar aldrigo commented on July 27, 2024

says it is not possible to install QR code, my tablet only has a front camera that must be why

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

says it is not possible to install QR code
Have you tried it with my demo QR code? It sounds like the configuration for the QR code is wrong.

from cordova-plugin-apkupdater.

aldrigo avatar aldrigo commented on July 27, 2024

I couldn't even test your QR code, after I entered the WIFI password, my device did that it's installing the QR code reader, but it can't install it, it must be known that it only has a front camera

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

Ah OK, that's weird. Is the internet connection restricted on the devices? Maybe the connection to Google is blocked. On my Android 7 device, a QR code reader is also downloaded and installed first.

The fact that the tablet only has a front-facing camera should not be a problem. The installed Reader supports both cameras.

from cordova-plugin-apkupdater.

aldrigo avatar aldrigo commented on July 27, 2024

there is no blocking, i will try on other tablets, i am disappointed... :(

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

I can't really help with that. I would guess that something is wrong with the Internet connection. Faulty DNS, ad blocker, restricted company network, etc.
It's a Google feature. That shouldn't actually break so easily.

from cordova-plugin-apkupdater.

aldrigo avatar aldrigo commented on July 27, 2024

greetings after updating (3.0.1) the plugin in my main project I'm getting an error in the download function: Class not found , could you help me please?

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

Can you give me the full error message? It works for me.

Here is my ionic test with an empty project:

ionic start test blank --type=angular --cordova --no-interactive
cd test
ionic cordova plugin add cordova-androidx-build --no-interactive --confirm
ionic cordova plugin add https://github.com/kolbasa/cordova-plugin-apkupdater#device-owner-reload --no-interactive --confirm
ionic cordova platform add android
ionic cordova run android -l

ionic info:

Ionic:

   Ionic CLI                     : 6.18.1 (@ionic/cli)
   Ionic Framework               : @ionic/angular 5.9.2
   @angular-devkit/build-angular : 12.1.4
   @angular-devkit/schematics    : 12.2.14
   @angular/cli                  : 12.1.4
   @ionic/angular-toolkit        : 4.0.0

Cordova:

   Cordova CLI       : 10.0.0
   Cordova Platforms : android 9.1.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 6 other plugins)

src/app/home/home.page.ts

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

import ApkUpdater 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(public platform: Platform) {
    platform.ready().then(this.update.bind(this)).catch(console.error);
  }

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

}

from cordova-plugin-apkupdater.

kolbasa avatar kolbasa commented on July 27, 2024

The changes are now in the master branch.
I'm going to close this one. If you have any questions, feel free to open it again.

from cordova-plugin-apkupdater.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.