New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

in-app-updates-capacitor

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

in-app-updates-capacitor

Enables In App Updates on Android using the official APIs.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-83.33%
Maintainers
1
Weekly downloads
 
Created
Source

in-app-updates-capacitor

Enables In App Updates on Android using the official Android APIs.

This plugin integrates the official Android APIs to perform in app updates that were released in 2019: https://developer.android.com/guide/app-bundle/in-app-updates


drawing drawing

Installation

npm i in-app-updates-capacitor
npx cap sync

Android

Register the plugin in your main activity:

import com.dwlrathod.inappupdates.InAppUpdatesPlugin;

public class MainActivity extends BridgeActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initializes the Bridge
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      // Additional plugins you've installed go here
      // Ex: add(TotallyAwesomePlugin.class);
      add(InAppUpdatesPlugin.class);
    }});
  }
}

iOS

iOS does not offer such functionality. If you call the methods above on an iOS device you'll run into a not-implemented exception.

Browser

If you call the methods above on a Browser you'll run into a not-implemented exception.

Usage

checkForUpdate()

Requests the update availability for the current app. This method need to call before calling startFlexibleUpdate or performImmediateUpdate.

import { Plugins } from "@capacitor/core";
const { InAppUpdatesPlugin } = Plugins;
import { AppUpdateInfo } from "in-app-updates";

InAppUpdatesPlugin.checkForUpdate().then(
    (updateInfo: AppUpdateInfo) => {
      console.log(updateInfo);
    },
    (error: any) => {
      console.error("error: " + error);
    }
  );

AppUpdateInfo interface:

  • updateAvailable: boolean;: Returns whether an update is available for the app.
  • immediateUpdateAllowed: boolean;: Returns whether the immediate is allowed.
  • flexibleUpdateAllowed: boolean; : Returns whether the flexible is allowed.
  • availableUpdateVersionCode: number; : If an update is available or in progress, this method returns the version code of the update.
  • availableUpdatePriority: number; : Returns the in -app update priority for this update, as defined by the developer in the Google Play Developer API.
startFlexibleUpdate()

Shows flexible update dialog. User will choose weather update or not.

InAppUpdatesPlugin.startFlexibleUpdate().then(
      () => {
        // Update downloaded complete and now you can start installing it. 
        // completeFlexibleUpdate()
      },
      (error: any) => {
        // User select No Thanks from update dialog.
        // error : user_canceled, no_update_found
      }
    );

flexibleUpdateStateChange listener will listen the status of downloading/downloaded update. You need to add the listener before calling startFlexibleUpdate.

import { FlexibleUpdateState } from "in-app-updates";

InAppUpdatesPlugin.addListener("flexibleUpdateStateChange", (info: FlexibleUpdateState) => {
      console.log("flexibleUpdateStateChange was fired  ", info.status);
      if (info.status) {
        this.appendEcho("status: " + info.status);
        this.appendEcho("bytesDownloaded: " + info.bytesDownloaded);
        this.appendEcho("totalBytesToDownload: " + info.totalBytesToDownload);
      }
    });
completeFlexibleUpdate()

For a flexible update flow, triggers the completion of the update. This method will only work with Flexible update and after update downloaded successfully.

InAppUpdatesPlugin.completeFlexibleUpdate().then(
      () => {
        // New update installation started succefully. 
      },
      (error: any) => {
        // error 
      }
    );
performImmediateUpdate()

Performs an immediate update.

InAppUpdatesPlugin.performImmediateUpdate().then(
      () => {
        // Immediate update started
      },
      (error: any) => {
        // error : user_canceled, no_update_found
      }
    );

Keywords

FAQs

Package last updated on 06 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc