Ionic appflow live update doesn't appear on device

Issue

I’m evaluating appflow as it’d be very useful for our project and would be keen to get one of the paid plans.

However, I don’t seem to be able to get the basic live deployments working with my Ionic/Angular/Capacitor app, and I’m a bit at a loss as to how to troubleshoot.

I have followed the docs and installed the SDK in my app.
I can see the app id, channel name (Production) and update method (auto) in string.xml and info.plist.

I have successfully built the app in appflow (web build), and I can see on the deployments screen my build assigned to the production channel of type ‘Live Update’.

I’m not seeing changes on device after the splash screen, so I’ve put together a screen using the ‘Deploy’ plugin to show me what version is installed, and if updates are available.

import { Deploy } from 'cordova-plugin-ionic/dist/ngx';

...

private async loadDeployInfo() 
{
    const info = await this.deploy.getCurrentVersion();

    if (info) {
      this.liveUpdateId = info.buildId;
    }    

    const updateCheck = await this.deploy.checkForUpdate();

    console.log(updateCheck);

    if (updateCheck.available) {
      this.updateAvailable = updateCheck.build;
    }    
  }

I call the above ‘loadDeployInfo()’ when my view loads and display out the build Id and whether an update is available. Neither show up anything when testing on device. I’m using capacitor, so running locally involves running ngx cap commands and opening android studio, which is not a tool I know how to get debug information out of, but I’m not seeing any red in the console as it’s running.

I’m a bit stuck. I’m keen to use app flow, but I’m not seeing basic live updates take effect and there’s not much documentation on troubleshooting.

Solution

From Ionic forum posts I’ve managed to piece things together. The long and short of it is that the ‘ionic deploy add’ command doesn’t seem to perform all the required configuration to make AppFlow work, at least on a Ionic/Angular/Capacitor based app.

Having followed the steps in the quick start guide here: https://ionic.io/docs/appflow/deploy/api

I needed to do the following:

To get Appflow going on Android, find ‘strings.xml’ in your Capacitor app’s ‘Android’ folder and add the following if they are missing:

  <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>

For iOS, find your Capacitor apps ‘ios’ folder and look for ‘info.plist’. Here you may find existing entries that look like they are coded to variables:

<key>IonApi</key>
<string>$UPDATE_API</string>
<key>IonMaxVersions</key>
<string>$MAX_STORE</string>
<key>IonMinBackgroundDuration</key>
<string>$MIN_BACKGROUND_DURATION</string>

Swap these $ variables for hard coded values:

<key>IonApi</key>
<string>https://api.ionicjs.com</string>
<key>IonMaxVersions</key>
<string>2</string>
<key>IonMinBackgroundDuration</key>
<string>30</string>

Update:

I logged a ticket on the git repo for the CLI, and they’ve updated it, so it may hopefully work for you without the above (make sure you’ve the latest ionic CLI).

Answered By – MIP

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published