0
votes

I am trying to use Ionic Cordova hot code push plugin to push updates from my server for my Android app.

The app gets updated automatically at first.

The second time, if I open the app, it opens with the older (installed) version.

What should I do to always open the updated version?

Steps I have done:

  1. Hot-code-push plugin installed.
  2. Cordova-hcp init.
    • Auto update at start.
  3. Added chcp tag to config.xml with server URL.
  4. ionic cordova build android
  5. cordova-hcp build.

How can I resolve this issue?

1

1 Answers

0
votes

I was trying this a few days ago. My guess is because Ionic serves the contents of the www/ folder in a different way than Cordova. Cordova uses a file scheme URL (file://www/index.html) whereas Ionic creates a virtual http server (http://localhost:8080). When HCP "updates" the app what it actually does is save the contents of the server URL in a different location (not the www/ folder) and navigates the webview to that location using the file scheme URL (data/emulated/0/user/blabla/updatefolder). Somehow it tells Cordova to always load those contents in the future unless it updates again, which Cordova does very well. But since HCP was not made with Ionic in mind it cannot tell Ionic to load the local server contents from that new folder therefore when the app is opened again it loads the contents that it was originally built with despite having the latest update downloaded locally.

To solve this we need to figure a way to tell Ionic to load the contents of the update instead of the original www/ folder.