Appflow live update, can't make it work

I was totally got wrong, and misunderstood what the development support team said that the live update feature is not free. What he actually said is that the live update feature for native binary is not free.
And he did not tell me the useful information, but I’ve got the very important information for live updates that is not in the document from google search finally I resolved the problem, and I decided to share it here.

As I tried the live update feature from the instruction from appFlow page like following:
linking with ionic link ${your_app_id} and ionic deploy add to set up Ionic Deploy.

1. Missing values

Then you can see some added text in the android/app/src/main/res/values/strings.xml:

...
  <string name="ionic_app_id">${your_app_id}</string>
  <string name="ionic_channel_name">Master</string>
  <string name="ionic_update_method">auto</string>

If you chaned the channel name and update method, it would be different.
Then if you run the application from Android Studio, you will meet the following error:

E/m.midas.jobfle: Invalid ID 0x00000000.
E/PluginManager: Uncaught exception from plugin
    android.content.res.Resources$NotFoundException: String resource ID #0x0
        at android.content.res.Resources.getText(Resources.java:363)
        at android.content.res.Resources.getString(Resources.java:456)
        at android.content.Context.getString(Context.java:580)
        at com.ionicframework.common.IonicCordovaCommon.getStringResourceByName(IonicCordovaCommon.java:341)
        at com.ionicframework.common.IonicCordovaCommon.getNativeConfig(IonicCordovaCommon.java:425)
        at com.ionicframework.common.IonicCordovaCommon.getPreferences(IonicCordovaCommon.java:384)
        at com.ionicframework.common.IonicCordovaCommon.execute(IonicCordovaCommon.java:92)
        at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)
        at org.apache.cordova.PluginManager.exec(PluginManager.java:132)
        at com.getcapacitor.MessageHandler.callCordovaPluginMethod(MessageHandler.java:69)
        at com.getcapacitor.MessageHandler.postMessage(MessageHandler.java:45)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:326)
        at android.os.Looper.loop(Looper.java:181)
        at android.os.HandlerThread.run(HandlerThread.java:65)
E/Capacitor/Console: File: capacitor-runtime.js - Line 2654 - Msg: Uncaught (in promise) String resource ID #0x0

You can see the error message related in chrome inspector Uncaught (in promise) String resource ID #0x0. It means that live update didn’t make due to the error.
In the process of loading and live updating the app, it checks some environmental values from strings.xml or SharedPreference. However, if there is some missing values, the process will stop and just go to the next step.
I found some missing value keys: ionic_max_versions, ionic_update_api, ionic_min_background_duration.
So, what you have to do is adding some additional values in strings.xml:

<resources>
...
  <string name="ionic_app_id">${your_app_id}</string>
  <string name="ionic_channel_name">Master</string>
  <string name="ionic_update_method">auto</string>
  <string name="ionic_max_versions" >2</string>
  <string name="ionic_update_api">https://api.ionicjs.com</string>
  <string name="ionic_min_background_duration">30</string>
</resources>

Then the error will be resolved and live update will done.
Next is additional information while I was solving the problem.

2. ionic_update_api

First, I’ve got the missing key values from debugging and tracking the code IonicCordovaCommon.java inside the Android proejct, so I did not know what that mean and what is the appropriate values for that keys. I found a hint from the merged commit (https://github.com/ionic-team/ionic-cli/pull/4065/files), but it was not helpful to find the appropriate value.
Then I typed the value for ionic_update_api like following:

<string name="ionic_update_api">https://api.ionicjs.com</string>

and the error happened:

Uncaught SyntaxError: Unexpected token < in JSON at position 0

After I resolved the problem, I now know that the api address for checking the update is wrong. I fond the appropriate value https://api.ionicjs.com googling almost a week. It means that you can manipulate the api address.
I don’t understand why this important information cannot be found anywhere.

Anyway, now the live update is perfectly done.
Thank you.
If you feel this answer is helpful, please like the blog post: https://dev.to/dotorimook/important-to-know-for-ionic-appflow-s-live-update-28hc

3 Likes