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-native-app-update

v2.0.0

Published

A plugin to check the App Store or Google Play Store for iOS and Android respectively.

Downloads

171

Readme

cordova-plugin-native-app-update · npm npm

By Austen Zeh


AppUpdate is a simple plugin for iOS and Android which will look for an app update through the App Store and Google Play Store respectively. This plugin was built to assist with the inconsistent review times by both Apple and Google after rolling out a new release version to production. This may also allow you to roll out a new version release for one OS, but not the other.

This plugin is defined as native because the app information is pulled right from the application itself using the native OS. Since the app information is gathered by the plugin, there is no need to provide an appID. However, because the plugin must make a request to either of the stores, the app will need a connection to make the request, and the update process will have to wait for the success callback to be executed. For more information on this please look below at the examples.

AppUpdate provides a needsUpdate method to check if an update is available in the OS store. This method returns a JSON object that will always contain update_available when the plugin executes successfully.

You are also able to provide an api url and api response key to make an api request to check app update type for a forced update. This api should be set up on your app server and should return a JSON object. The JSON object that is returned from the api response is appended to the object returned by the plugin, so you will have access to more than just the update_available flag.

:new: The Android version of the plugin has been updated to use the in-app updates functionality, which is the recommended way to check for Android app updates.

iOS

  • Currently, for iOS devices, the plugin checks the version number, not the build number, so if you release multiple builds within the same version, then this plugin will not handle these updates properly. (ex. 1.0.0 != 1.0.1)
  • This plugin may be updated in the future to handle multiple builds within the same version, but seeing as Apple requires a new version number for new releases this may not be necessary at all.
  • update_available has a value of type boolean

Android

  • This plugin uses Android's in-app updates functionality to check for app updates
  • update_available has a value of 1 or 0 which will evaluate to a boolean, so Android does not need to be handled differently
  • If no api response key is passed in, then force_update will be returned by the plugin also and the value will be determined using Android's in-app updates functionality

Requirements

iOS

  • No requirements, the plugin should work immediately after installing.

Android

Installing the plugin

  • NPM

npm install --save cordova-plugin-native-app-update
  • Ionic

ionic cordova plugin add cordova-plugin-native-app-update
  • Pure Cordova

cordova plugin add cordova-plugin-native-app-update
  • PhoneGap CLI

phonegap plugin add cordova-plugin-native-app-update
  • PhoneGap Build

<plugin name="cordova-plugin-native-app-update" spec="https://github.com/kungfu-king-betty/cordova-plugin-native-app-update.git" />

Using the plugin

  • The plugin creates the AppUpdate object, to used in your app
  • Call the needsUpdate method with a success handler and error handler
  • (Optional) Call the needsUpdate method with a success handler, error handler, force_api_url, force_api_response_key
  • In the success handler, check the update_available value to determine your next move
  • In the success handler, you can also check the force_update value to handle forced updates

Example

Pure Cordova Javascript (eg: Cordova, Ionic, PhoneGap)

onDeviceReady: function () {
    // Example #1: WITHOUT API URL
    AppUpdate.needsUpdate(function(appUpdateObj) {
        if(appUpdateObj.update_available == 1) {
            // App Update Detected
            var appUpdateMsg = "App Update Detected";
            if (appUpdateObj.force_update == 1) {
                appUpdateMsg = `FORCE! ${appUpdateMsg}`;
            }
            
            alert(appUpdateMsg);
        } else {
            // NO App Update Detected
            alert("No App Update Available");
        }
    }, function(error){
        alert("App Update ERROR:",error);
    });
    
    // Example #2: WITH API URL
    AppUpdate.needsUpdate(function(appUpdateObj) {
        if(appUpdateObj.update_available == 1) {
            // App Update Detected
            var appUpdateMsg = "App Update Detected";
            if (appUpdateObj.force_update == 1) {
                appUpdateMsg = `FORCE! ${appUpdateMsg}`;
            }
            
            // Use custom key/values returned from the api call
            if (appUpdateObj.custom_force_key) {
                appUpdateMsg = "Custom App Force Update Available";
            }

            alert(appUpdateMsg);
        } else {
            // NO App Update Detected
            alert("No App Update Available");
        }
    }, function(error){
        alert("App Update ERROR:",error);
    }, "https://localhost/appupdatetest/test", "custom_force_key");
}

TODO Items

  • Add wiki/docs for the AppUpdate plugin
  • [Android] Possibly updated the plugin to use Android's in-app updates functionality to install the app update as well as check an available update

License

The MIT License

Copyright (c) 2020 Austen Zeh

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.