|
12/16/2020, 09:01 PM
#56
Update Service from App Museum II
Mojo and Enyo libraries and code samples are here:
https://github.com/codepoet80/webos-.../main/Examples
The update process has three steps, all of which are implemented in the above libraries and work on all webOS devices that support Mojo or Enyo.
CheckForUpdate (appname, callback)
Unfortunately, the Museum "master" metadata does not include the webOS app id, so you have to pass in an app name, or museum ID, that it knows about. If this were a real AppStore, that would be untenable, since the final app name and store GUID would not be known at design time. But since there's only a few of us left, and a finite number of apps in the Museum, I think we can live with this.
Given the name you pass in, the Model will ask the Museum for the latest version, and compare that response to the built-in webOS app information, to see if the currently running app is older than the museum version. The response from the museum contains meta data about the latest app version, which will be augmented with a boolean value indicating if your app has an update.
PromptUserForUpdate (callback, message)
This function is entirely optional -- you can choose to handle this yourself if you prefer. If you'd rather not be bothered, just call this function if an update is indicated by the CheckForUpdate callback. You can also optionally over-ride its auto-constructed message to the user if you like everything about this UI except for the text. When called, this function will inform the user of the update availability, and if you don't over-ride the message, will give them the last line of the versionNote meta data from the Museum's response. A boolean value sent to the callback indicates if the user accepts the update, or declines it.
You can directly call the next function in your callback handler (you just need to evaluate the boolean response from the user first!)
InstallUpdate
This function will call Preware, passing the URL to the updated version .IPK given by the Museum response.
Once Preware is called, your app's "card" will be moved to the background, Preware will become the foreground app and will forcibly replace your running app with the new version from the Museum -- assuming the Museum is up, the device is still connected to the Internet, etc...
If the update fails for any of the above, or other, reasons, the user will have to swipe away the Preware card to return to your running, and unaltered app.
Here's a screenshot of the auto-generated Mojo UI on a Pre:
onenightstand_2020-16-12_210233.png
|
|
|