Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cordova-plugin-hotpushes

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-hotpushes

Simple Hot pushes

  • 0.6.0
  • latest
  • Source
  • npm
  • Socket score

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

#cordova-plugin-hotpushes

Download and cache remotely hosted content.

This plugin is a work in progress and it is not production ready. PR welcome.

Installation

cordova plugin add cordova-plugin-hotpushes

Supported Platforms

  • Android
  • iOS
  • WP8

Examples

  • Replace example
  • Merge example

API

HotPush.sync(options)

ParameterDescription
options.srcString URL to hot push endpoint
options.versionFileNameString Name of the json file containing the version information
options.typeString (Optional) Defines the hot push strategy applied to the content.
The type HOTPUSH_TYPE.REPLACE is the default behaviour that completely removes existing content then copies new content from a zip file.
The type HOTPUSH_TYPE.MERGE will download and replace only content which has changed.
options.headersObject (Optional) Set of headers to use when requesting the remote content from options.src.
options.archiveURLString (Mandatory if options.type === Hotpush.HOTPUSH_TYPE.REPLACE) URL of the zip containing the files to hot push.
options.documentsPathObject (Optional) Path to the Documents folder (useful for WKWebView)
options.checkTypeString (Optional) Set to Hotpush.HOTPUSH_CHECK_TYPE.VERSION if you want to use the version number in your version.json instead of timestamp
options.debugBoolean (Optional) Print debug information in the console

Returns

  • Instance of HotPush.

Example

var hotpushes = HotPush.sync({
  src: 'http://myserver/hot/',
  versionFileName: 'version.json',
  type: Hotpush.HOTPUSH_TYPE.REPLACE,
  archiveURL: 'http://myserver/hot/assets.zip'
});

hotpushes.loadWaitingLocalFiles()

Load the local files at position -1 (see version.json).

ParameterDescription
no parameters

hotpushes.loadAllLocalFiles()

Load the local files at position >= 0.

ParameterDescription
no parameters

hotpushes.check()

Check if there is a new version available on the server.

ParameterDescription
no parameters

hotpushes.update()

Download the files on the server.

ParameterDescription
no parameters

hotpushes.on(event, callback)

ParameterDescription
eventString Name of the event to listen to. See below for all the event names.
callbackFunction is called when the event is triggered.

hotpushes.on('updateFound', callback)

The event updateFound will be triggered when a new update is found on the server.

Callback ParameterDescription
no parameters
Example
hotpushes.on('updateFound', function() {
  hotpushes.update();
});

hotpushes.on('noUpdateFound', callback)

The event noUpdateFound will be triggered when no new update is found on the server.

Callback ParameterDescription
no parameters
Example
hotpushes.on('noUpdateFound', function() {
  alert('All good!');
});

hotpushes.on('progress', callback)

The event progress will be triggered on each update as the native platform downloads and caches the content.

Callback ParameterDescription
data.progressInteger Progress percentage between 0 - 100. The progress includes all actions required to cache the remote content locally. This is different on each platform, but often includes requesting, downloading, and extracting the cached content along with any system cleanup tasks.
data.statusInteger Enumeration of PROGRESS_STATE to describe the current progress state.
Example
hotpushes.on('progress', function(data) {
    // data.progress
    // data.status
});

hotpushes.on('updateComplete', callback)

The event updateComplete will be triggered when the content has been successfully cached onto the device.

Callback ParameterDescription
no parameters
Example
hotpushes.on('updateComplete', function() {
  location.reload();
});

hotpushes.on('error', callback)

The event error will trigger when an internal error occurs and the cache is aborted.

Callback ParameterDescription
eError Standard JavaScript error object that describes the error.
Example
hotpushes.on('error', function(e) {
    // e.message
});

hotpushes.on('cancel', callback)

The event cancel will trigger when hotpushes.cancel is called.

Callback ParameterDescription
no parameters
Example
hotpushes.on('cancel', function() {
    // user cancelled the hot push
});

hotpushes.cancel()

Cancels the content sync operation and triggers the cancel callback.

HotPush.PROGRESS_STATE

An enumeration that describes the current progress state.

IntegerDescription
0STOPPED
1DOWNLOADING
2EXTRACTING
3COMPLETE

HotPush.HOTPUSH_TYPE

An enumeration that describes the type of hotpush to perform.

StringDescription
mergeMERGE
replaceREPLACE

HotPush.HOTPUSH_CHECK_TYPE

An enumeration that describes the field to look at in the version.json file.

StringDescription
versionVERSION
timestampTIMESTAMP

Keywords

FAQs

Package last updated on 17 Nov 2015

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