Hi! I’ve integrated ionic live updates into my app recently.
Now I have a problem with snapshot version: app always loads old snapshot if I load new app version via Xcode or ionic-cli.
Only able to load new version by deleting app from device.
Xcode v. 8.3.3
Ionic v. 3.4.0 (with ionic-v1 app)
Cordova v. 7.0.1
ionic-plugin-deploy v.0.6.7
Steps to reproduce:
Install binary via xcode or ionic-cli run
make code changes and upload snapshot with “ionic upload --note “some note” --deploy dev” command
check for updates, download and extract snapshot ( $ionicDeploy.check(), download(), extract() )
do not apply snapshot at the moment
make some changes in the app
update binary via Xcode or ionic-cli run
Result: loaded old version from snapshot
Expected result: latest code changes should be reflected.
Also if I run “ionic run ios --device --livereload” code changes not reflected. It worked perfectly before implementing deploy.
Additional info:
Livereload partially works - if I close app manually and start it again - I can see changes. But it still won’t reload automatically on changes and no console output (running with “ionic run ios -l -c -s”)
Can you please elaborate what you do step by step, include the ionic upload command, when you deploy in apps.ionic.io etc. - more details are needed to understand and then fix your problem. (Giving the “versions” a “name” or “number” in the description usually helps, too)
(Also post your ionic info output for good measure)
In other words: App still uses last deploy snapshot even after binary update.
I assume it just loads last snapshot ignoring current www directory content.
ionic info:
global packages:
@ionic/cli-utils : 1.4.0
Cordova CLI : 7.0.1
Gulp CLI : CLI version 1.2.2 Local version 3.9.1
Ionic CLI : 3.4.0
Sequence in app (called manually, no automatic deploys):
$ionicDeploy.check() //returns true
$ionicDeploy.download() // download ok
$ionicDeploy.extract() // extract ok
After successful deploy app always uses last snapshot. I still able to push updates via deploy, but binary updates totally ignores changes in JS files.
I didn’t set Equivalent, Minimum or Maximum version in web interface, but I only checking for updates manually, so it can’t overwrite last binary update after launch.
Sorry, I still don’t understand the chronological order and e.g. what you mean by [quote=“allforfree, post:1, topic:96713”]
update binary via Xcode or ionic-cli run
[/quote].
Please write a chronological order of events that break things for you.
Under binary update I mean for example command: ionic cordova run ios --device
Same result can be achieved by installing updated version via testflight or from App Store.
For testing purposes I’ve implemented version constant into app.js.
Below chronological order with constant output.
Install binary. Success. Installed version: 0.2.1
Make changes in app.js. Set version to 0.2.2
Update via deploy - success. Got version 0.2.2 - works as expected.
Make changes in app.js Set version to 0.3.1
Binary update - success. But version is still 0.2.2
Delete app from device.
Install binary. Success. Version: 0.3.1 - expected same result on step 4.
How can I make binary update to last version without deleting app from device?
It’s just a constant named version in the app.js file. config.xml remains the same all the way.
Lets call it app.js file version.
Same. Constant in app.js
Not exactly, but close to. Means executing ionic upload --note "note" --deploy dev command from ionic-cli.
But I think we’ll get same result by setting active snapshot at apps.ionic.io
ionic cordova run ios --device because it’s faster.
Or I can load Xcode ant click “Run”, or I can upload new archive into testflight - same result.
Same. Run command from ionic-cli: ionic cordova run ios --device
No commands between. Only difference that app was deleted from the device between steps 5 and 7. Deleted using touchscreen on the device, no commands.
I am asking so specific to understand when and how your app where you edit files makes the move from your project directory to the copy of www inside the platforms folders which is used to build. Could it be that this doesn’t actually happen between steps 4 and 5 but between steps 6 and 7? (I am not that fluent with Ionic v1 any more… with Ionic v2+ you would have to somewhere trigger a build from src to www that would then be used with run)
Alternative thought: Are you sure the binary is replaced at 5)? Maybe the device sees that it is the same binary version (from config.xml) and doesn’t change the file then? As you still see 0.2.2 in 5) this could somehow be the case…
Fresh app installation, never updated via deploy. Updates with cordova run command, version changes as expected every time. After first deploy version remains the same as in last snapshot.
changed app version in config.xml and constant in app.js. App version in iOS “Manage Storage” screen changed to new version as I set in config.xml. Constant in app.js remains same as in unmodified version from deploy snapshot.
It compiles during cordova run command. Verified with check n.1
Not possible. I only call deploy update manually. I also checked in flight mode without internet - same result. It definitely uses snapshot version from previous deploy update, not downloading it again.
Update: one more check. I’ve changed active deploy version on apps.ionic.io to very old version. Launched version from last deploy. Version downgrades only after I run deploy manually from the app.
So there is no hidden automatic deploys.
As I already answered - app version in iOS information changes, but app still uses old JS files. So it didn’t help. But this way we can know that binary really updated.
Ok, then something is very wrong or strange here: When the binary is updated, really exchanged on the device, also the www content is replaced.
Only thing I can now thing of is that the unpackaged snapshots of Deploy stay on the device, so when the new app starts it again loads this snapshot from before. Only by uninstalling the app, you remove the unpackaged, previously used snapshots and then get a the correct www from inside the ipa.
Ok, that acutally makes sense, doesn’t it?
To test this you would have to install the binary from 1) with 0.2.1 in step 5) again - can you test that? It will probably still be 0.2.2 after that - which also makes sense as the “normal” use case for Ionic Deploy would probably be that you make multiple snap shots, then only the app you uploaded to the store a week ago gets released with a new binary but the now obsolete www - and you don’t want to go back to that old version from the store but stay on the already deployed snapshot. Right?
Yes, www content is replaced on binary update, but snapshot remains on device. And app launches scripts from old snapshot, not from updated www folder.
I’ve tested it several times - if no snapshots present, it uses script from www. Otherwise it loads scripts from snapshot ignoring updated www folder which comes with new binary.
I don’t think that such behaviour is normal use case: Imagine that somebody accidentally have deployed broken snapshot(parse error in js, or smth like this). App is dead from this moment. You can’t update it via deploy, because it’s broken and won’t launch deploy check. And even App Store update can’t fix it because app will load broken script from snapshot.
You probably shouldn’t deploy broken snapshots then
Yes, you are probably right. Maybe there is another way to handle that?
Setting a max version for the “broken” build lower than the one you are updating to might work.
Setting max version BEFORE deploying snapshot and then changing app version in config.xml helps.
But if you are using ionic-cli deploy command it’s not possible to set max version in the cli. So snapshots deployed via cli command will never expire if somebody install it before you set max version on the website.
My suggestions:
ionic-cli ionic upload --deploy command should allow setting min, max and equivalent version of snapshot. Maybe it’s good idea to add command line option for setting max version to next minor version. E.g. your app version 0.2.14 and max snapshot version automatically sets to 0.3.0
Documentation of deploy service doesn’t contain information that your app will be rejected by Apple if you add update confirmation dialog to your app. Probably it should be mentioned.
More explanations required on this part of documents:
Also a good idea to implement addition $ionicDeploy function for deletion all downloaded snapshots except active one. It’s very common use case, but for now developers must write their own implementations with recurring promise chains for deleting old snapshots from device.
All the others things you said are true, but Ionic Deploy itself hasn’t received updates for quite some time - I think Ionic might be working on an updated version of the service. See Where we're going with "Cloud" - Ionic Blog for that.