npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-in-app-updates

v2.2.0

Published

In-App updates from Play Store for your Apache Cordova app.

Downloads

299

Readme

npm npm GitHub package.json version GitHub code size in bytes GitHub top language GitHub GitHub last commit

cordova-plugin-in-app-updates

Cordova Android plugin for checking for updates and auto updating app with Google Play Store In-App updates API.

Platforms

  • Android
  • Browser (filler platform)

Features

  • AndroidX ready (plugin version 2.x.x)
  • Check for updates
  • Install flexible updates
  • Install immediate updates
  • Customize snackbar message and button for Flexible updates
  • Customize snackbar button color for Flexible updates

Installation

Plugin Versions

| Plugin version | Cordova >= | Cordova Android | AndroidX | targetSdkVersion | | --- | --- | --- | --- | --- | | 1.0.6 | 9.0.0 | 8.0.0 | No | 29 | | 2.0.5 | 10.0.0 | 9.0.0 | Yes | 30/31 | | 2.1.0 | 10.0.0 | 11.0.0 | Yes | 32 | | 2.2.0 | 10.0.0 | 12.0.0 | Yes | 33 |

Install latest version from NPM

  cordova plugin add cordova-plugin-in-app-updates

Install latest version from master

  cordova plugin add https://github.com/andreszs/cordova-plugin-in-app-updates

Methods

getUpdateAvailability

Invokes the AppUpdateManager and return one of the updateAvailability codes as string.

cordova.plugins.InAppUpdate.getUpdateAvailability(successCallback, errorCallback)

Return values

  • UPDATE_AVAILABLE
  • UPDATE_NOT_AVAILABLE
  • DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS
  • UNKNOWN

:information_source: Browser platform does nothing and always returns UPDATE_NOT_AVAILABLE

When this method returns UPDATE_AVAILABLE, your app is ready to use the following methods to prompt the user for update.

Example

var onSuccess = function (strSuccess) {
   console.log(strSuccess);
};
var onFailure = function (strError) {
   console.warn(strError);
};
cordova.plugins.InAppUpdate.getUpdateAvailability(onSuccess, onFailure);

updateFlexible

Starts a flexible update process and prompts the user with a dialog to download the new version now or when Wi-Fi is available.

cordova.plugins.InAppUpdate.updateFlexible(successCallback, errorCallback)

:warning: The successCallback from this method can be triggered repeatedly according to its status.

Return values

  • UPDATE_NOT_AVAILABLE: No updates available in Play Store.
  • DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS: Either flexible or immadiate update is in progress.
  • UPDATE_PROMPT: The user has been presented with the Play Store dialog to download or ignore the flexible update.
  • RESULT_OK: User accepted to download flexible update.
  • RESULT_CANCELED: User declined the flexible update dialog or update was aborted while in progress.
  • RESULT_IN_APP_UPDATE_FAILED: Something went wrong with the update dialog response.
  • ACTIVITY_RESULT_UNKNOWN: Unknown result code returned by the dialog.
  • DOWNLOADING: An update is currently being downloaded in the background.
  • DOWNLOADED: The update was downloaded and the snackbar with RESTART button has been shown.

:information_source: Browser platform does nothing and always returns UPDATE_NOT_AVAILABLE

Example

var onSuccess = function (strSuccess) {
    console.log(strSuccess);
};
var onFailure = function (strError) {
    console.warn(strError);
};
cordova.plugins.InAppUpdate.updateFlexible(onSuccess, onFailure);

:warning: Make sure to call getUpdateAvailability as often as needed to ensure there are no flexible updates downloaded pending install, as they will consume storage space until installed.

updateImmediate

Starts an immediate update process and prompts the user with a fullscreen dialog to download now or when Wi-Fi is available. The update is downloaded and installed in the foreground, preventing the user from interacting with your app until the installation succeeds and the app is automatically restarted.

cordova.plugins.InAppUpdate.updateImmediate(successCallback, errorCallback)

:warning: The successCallback from this method can be triggered repeatedly according to its status.

Return values

  • UPDATE_NOT_AVAILABLE: No updates available in Play Store.
  • DEVELOPER_TRIGGERED_UPDATE_IN_PROGRESS: Either flexible or immadiate update is in progress.
  • RESULT_OK: User accepted to download immediate update.
  • RESULT_CANCELED: User declined the immediate update dialog.
  • RESULT_IN_APP_UPDATE_FAILED: Something went wrong with the update dialog response.
  • ACTIVITY_RESULT_UNKNOWN: Unknown result code returned by the dialog.
  • DOWNLOADING: An update is currently being downloaded in the foreground.
  • DOWNLOADED: The update was downloaded and will be installed immediately.

:information_source: Browser platform does nothing and always returns UPDATE_NOT_AVAILABLE

Example

var onSuccess = function (strSuccess) {
    console.log(strSuccess);
};
var onFailure = function (strError) {
    console.warn(strError);
};
cordova.plugins.InAppUpdate.updateImmediate(onSuccess, onFailure);

setSnackbarOptions

Sets the label and the button text for the snackbar shown after downloading a flexible update. You are free to call this method at any time. You can also call it again to show different snackbar messages after the snackbar was shown.

cordova.plugins.InAppUpdate.setSnackbarOptions(successCallback, errorCallback,  snackbarText, snackbarButton, snackbarButtonColor)

:information_source: Browser platform does nothing and always returns SUCCESS

Example

var onSuccess = function (strSuccess) {
    console.log(strSuccess);
};
var onFailure = function (strError) {
    console.warn(strError);
};
var snackbarText = "An update has just been downloaded.";
var snackbarButton = "RESTART";
var snackbarButtonColor = "#76FF03";
cordova.plugins.InAppUpdate.setSnackbarOptions(onSuccess, onFailure, snackbarText, snackbarButton, snackbarButtonColor);

Snackbar default values

If this method is not called, default messages in English will be shown as follows.

  • snackbarText = "An update has just been downloaded."
  • snackbarButton = "RESTART"
  • snackbarText = "#76FF03"

Return values

  • onSuccess = "SUCCESS"
  • onFail = Internal error description.

Plugin demo app

Changelog

2.2.0

  • Optimized for android-compileSdkVersion 33
  • Minimum cordova-android version set to 12
  • Updated androidx.appcompat:appcompat to 1.6.1
  • Updated com.google.android.material:material to 1.8.0

2.1.0

  • Optimized for android-compileSdkVersion 32
  • Minimum cordova-android version set to 11
  • Replaced com.google.android.play:core with the standalone Play In-App Updates Library 2.1.0
  • Updated androidx.appcompat:appcompat to 1.5.1
  • Updated com.google.android.material:material to 1.3.0
  • Removed the edit-config rule that was setting android:theme="@style/Theme.AppCompat.NoActionBar"
  • Tested on Android 5.1, 8.1, 10.

2.0.5

  • Optimized for android-compileSdkVersion 30
  • Updated androidx.appcompat:appcompat to 1.3.0
  • Updated com.google.android.play:core to 1.8.0
  • Updated com.google.android.material:material to 1.2.0