How to apply Live Updates manually? (Ionic docs out-of-date)

The current “background” live updates seem to work sporadically and unreliably: it randomly applies the updates to some users but not others. Sometimes the updates happen in a short time, sometimes in an hour. This used to work better before migrating from Cordova plugins to Capacitor 5.

The real issue, however is, that I’m trying to change the live updates method to “none” to apply live updates manually. Unfortunately the API documentation seems to be out-of-date. It tells you to install “cordova-plugin-ionic” (to be able to use the Deploy plugin) even though this is removed when migrating from Cordova to Capacitor. Also, when I try to re-install this plugin, the app no longer even starts.

Please provide information on how to use the autoUpdateMethod “none” method to apply Live Updates manually without using Cordova plugins.

Current live updates API documentation:

Live Updates API

cordova-plugin-ionic is 100% compatible with Capacitor.
What did you do to migrate from Cordova to Capacitor? I’m not aware of any migration tool that does that, and if there is one it should not remove cordova-plugin-ionic.

There is a new Capacitor plugin now, but it’s still in beta (but it’s pretty stable, don’t let the beta word scare you). It doesn’t support all the same features yet, but should allow you to set the download method to none and programmatically check for updates.

Thanks for the quick response, Julio. I think I may have misinterpreted the migration instructions which state that

“After replacing a Cordova plugin with a Capacitor one (or simply removing it entirely), uninstall the plugin then run the sync command to remove the plugin code from a native project: npm uninstall cordova-plugin-name”

I guess this does not mean to remove that particular plugin.

However, when I re-installed cordova-plugin-ionic, my app stopped starting with the following cryptic error which I have not encountered before and have no clue what it means:

Uncaught (in promise) String resource ID #0x0

I have installed the new live-updates plugin and will attempt to use that.

Yeah, that only means to uninstall the plugins you might not need anymore, but if you want live updates you still need cordova-plugin-ionic (unless you want to give @capacitor/live-updates a try, but it’s pretty new, didn’t exist when that guide was created).

That error appears when the cordova-plugin-ionic plugin is not configured, in Cordova you’ll configure it by using cordova plugin add cordova-plugin-ionic --app-id=youId --channel-name=yourChannel --update-method=theUpdateMethod, but for Capacitor, since the plugins are installed using npm there is no way of passing the variables. So Ionic CLI added a new command to configure live updates in Capacitor projects (I think it also works for Cordova projects). The command is ionic live-update add, that will prompt for the app id, channel name and update method. Or you can also use ionic live-update configure to change existing values.
What those commands do is just to copy those values to native files (Info.plist, strings.xml), you could change/add those values manually too, but the command makes it easier.

1 Like

Thanks very much for the detailed explanation. You can mark this issue solved. :slight_smile: