How to disable Appflow Live Updates in IONIC app - ionic-framework

I have Ionic Appflow Live Updates configured and deploying correctly (in a Capacitor project). The problem is that when I deploy manually the app to my phone in order to do some development tests, it logically keeps updating to the latest Appflow deployment. I'd like to disable Live Updates temporarily, in order to be able to test a new version in my phone, without being it updated. Is this possible?

There is a way to configure your app to disable updates: in capacitor.config.json file add the following to the cordova.preferences object:
{
...
},
"cordova": {
"preferences": {
"DisableDeploy": "true"
}
}
}
This should stop auto updating your test app. Remember to revert it to false before commiting the project for Appflow deployment.
Read the Documentation.

Related

Ionic appflow live update doesn't appear on device

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

Installed PWA is not updating

I have developed a PWA using Quasar framework. I didn't change anything in service-worker or manifest file, just going with defaults.
I have hosted the build on AWS S3 facing a cloud-front distribution.
When I push the updated build on S3 and invalidate the cloud-front distribution cache. The user who opens the website via browser gets an updated version. but users with installed PWA never get the updates unless they open the website again in the browser.
I have planned to update changes every other day. what is the best way that whenever I push change installed PWA gets updated instantly?

Publishing app with Ionic deploy iOS, and android

I am new to app development and have been using the ionic framework to build my app. I am ready to publish, and want to use ionic deploy, as it seems efficient.
My question is do I need to upload my app to Apple/play store before I can use Ionic deploy, or can I use ionic deploy when publishing for the first time?
You must first publish and release your app using the standard store process, here is a good guide to help with it.
Then you can use Ionic Deploy for subsequent deployments / releases.

How to get Ionic Pro Deploy to download latest version on first app open

Problem
When I release a new version to the production channel in Ionic Pro Deploy (Channels) then I have to cycle my app twice in order to get the latest version. Even worse, on the first cycle my app reverts back to a far earlier version for some reason.
What I mean by cycling is, starting from a state where the application is shut down and not open, I open the app, wait for the splash screen to go away and app to be ready, and then close the app.
Question
How do I get my app to download the latest version on the very next time I open the Ionic app following my production release?
Plugin configuration
I used the plugin config from the dashboard.ionicjs.com page:
cordova plugin add cordova-plugin-ionic --save \
--variable APP_ID="[myappid]" \
--variable CHANNEL_NAME="Production" \
--variable UPDATE_METHOD="background"
Execute the command you already showed but set UPDATE_METHOD to "auto"
If you wand more control over your updating methods have a look at this:
https://ionicframework.com/docs/pro/deploy/plugin-api.html
In my case, live deploy worked correctly on a "blank" Ionic project. Live deploy also worked correctly on "my" app on iOS but not on Android.
I followed the follow steps and successfully fixed Android. However, during this process iOS suddenly had the same problem (would apply update on app install/close/open).
Set versions as per Ionic support. IonicPro live deploy currently requires these versions. Ionic are in the process of fixing this dependency:
"cordova-plugin-ionic-webview": "1.1.19",
"cordova-plugin-ionic": "4.1.7",
Install a new version of "blank" project. Update my app to use the same npm plugin versions (some of my app plugins were old).
Remove/add android platform. My hunch is this is what ultimately resolved the issue.
I wanted to try a remove/add ios platform to see if that also resolved the issue on iOS. But it was less work to ultimately switch over to IonicPro rather than re-config the local build setup.
Live deploy worked correctly on both iOS and Android after creating binaries in IonicPro.

Ionic serve / ionic run not reflecting changes

Both ionic serve and ionic run are not reflecting any of my latest changes. ionic serve is showing them from a few hours ago, and ionic run is showing them from about an hour later. Since then, I've discarded all my changes, and created a new branch from the parent--yet it's still showing those same versions from a few hours ago on the first branch. In short, there's code showing up that I don't have in any files in this, or any, branch. And no uncommitted changes.
Your system information:
Cordova CLI: 6.5.0
Ionic CLI Version: 2.2.2
Ionic App Lib Version: 2.2.1
ios-deploy version: 1.9.0
ios-sim version: 5.0.8
OS: macOS Sierra
Node Version: v6.10.1
Xcode version: Xcode 8.3.1 Build version 8E1000a
I've tried things including ionic state restore and ionic state reset as well as removing and adding platforms back manually.
Also, this is what shows up in my console currently:
Static file server running # http://localhost:8000/index.html
CTRL + C to shut down
200 /service-worker.js
Whereas it previously displayed a list of html, css, etc. requests when the page loaded. Currently, I can make it work as expected by unregistering and removing all ServiceWorkers at chrome://serviceworker-internals/ and chrome://inspect/#service-workers
#stephen, it's been some time now, but I faced a similar issue before. Turns out I had registered the service worker that ships with projects created with the CLI, check your index.html and see if the lines that register the service worker are commented out. If they are you may be having a different problem, if they aren't and you didn't plan to use a service worker, comment them out again, and on your browser (you said chrome), after running ionic serve, open "Inspect" (Ctrl+Shift+I), go to the "Application" tab - "Service Workers" and unregister it.
This happens because the service worker that ships with new projects created using the cli will cache all resources, next time you update your code the browser will load the previous version, that's why you don't see the changes.
Hope it helps
Open the developer console, right click on the button to reload the page and click on empty cache and reload in a forced way (Last option).