Ionic Deploy get metadata of available update (not installed snapshot)

I’m using Ionic Deploy. I want to give my users the option to update now or later, but I also want to require some snapshots to be used no matter what (e.g. the API is changing, and we want all users to get the latest snapshot that uses the new API).

To do so, I’m setting metadata on snapshots, e.g. required metadata to true.

Then, when checking if there are any snapshot updates available, I want to look at metadata and either force the new snapshot to be downloaded or let the user decide when to download the new snapshot.

My issue is that the Ionic deploy check() only returns true or false… no information on the available update.

getMetadata()'s source says this:

Fetches the metadata for a given snapshot. If no UUID is given, it will attempt to grab the metadata for the most recently known snapshot.

I don’t want the metadata of the currently installed snapshot. I want the metadata of the available snapshot. But, I have no way of getting the uuid of the available snapshot, so I have no way of knowing if the available update is required or not.

Is there a better way to handle required snapshots?

I think I had this implemented a year ago… just have to find the source of that project…

Well, that was a nice trip down memory lane of Ionic v1.

Unfortunately, I found this comment:

This can not work yet, as there is no deploy_id returned when checking for availability of a snapshot.

So my code actually assumed some values.

I don’t think this ever got added :frowning:

I was mistaken. Calling getMetadata() in check() returns metadata for the available snapshot. I was just confused by the documentation “grab the metadata for the most recently known snapshot”.

I have it working well where some snapshots get force-downloaded/extracted/reloaded based on metadata, and other snapshots are optional where the user can decide to download now or get reminded in an hour, and when downloaded they can decide to reload the app now or later.

I also have this as a second AngularJS app so JS errors in the primary app don’t prevent the Ionic Deploy app from doing its thing and using a new snapshot in that scenario.

Thanks for checking!

Whoah, that means my code would have worked had I actually implemented setting the var to returned values instead of dummy data. Now I kind of want to fix that - unfortunately this is not my project any more :wink:

*checking.github *

Yes, you are totally right:

Actual logic for getting the “current deployment id” then is in the Cordova plugin part:

Interestingly it always seems to have tried to get the last deploy:

So I should have been able to get my thing working back in the day… *hmm

Nice. How do you handle the “reload flash” happening during deployment?

That sounds interesting. Care to elaborate a bit? Maybe in a new “demo” topic about that.