1.0.5 • Published 8 years ago

catapush_phonegap v1.0.5

Weekly downloads
21
License
SEE LICENSE IN LI...
Repository
-
Last release
8 years ago

Catapush PhoneGap / Cordova / Ionic Library

Introduction

Set of tools to easily implement Catapush in your PhoneGap / Cordova / Ionic hybrid project.

Download

The library can be downloaded here: full version, minified version. If you are using npm (package.json) you can install it with:

npm install catapush_phonegap

Usage

Load the library and its dependencies:

<link type="text/css" href="catapush-widget.css" rel="stylesheet">

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/strophe.js/1.2.6/strophe.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/ydn.db/0.9.2/ydn.db-isw-core-qry.js"></script>
<script type="text/javascript" src="catapush.js"></script>
<script type="text/javascript" src="catapush-widget.js"></script>
<script type="text/javascript" src="catapush-phonegap.js"></script>

create a div container

<div id="catapush-widget"></div>

Load the widget, the library and connect using an existing Catapush user:

    var catapush = Catapush.get();
    $('#catapush-widget').catapushWidget({
        'appKey': 'yourAppKey',
        'platform' : Catapush.PLATFORM.ANDROID, // Platform as defined in Catapush Library
        'user' : 'userIdentifier',
        'password' : 'userPassword',
        'instance': this.catapush
    });    
    CatapushPhonegap.start(this.catapush);

Use the api provided by the library to add notification handlers and more.

API

Functions

  • getPlatformId - obtain current platform id as required by Catapush Api
  • updateToken (token) - update current push token using Catapush API
  • setupPush - setup Push notification through plugin phonegap-plugin-push
  • getOnForeground - returns true if app is currently in foreground
  • alert (message) - show simple alerts, using Toastr when possible
  • starts - starts the plugin
  • attachment - handlers used to store and read attachments, can be used to set jquery widget handlers

Events

  • onShow - triggered when application is put on foreground
  • onHide - triggered when application is removed from foreground (closed or hidden)

Dependencies

The app depends on four libraries:

  • jQuery - v. 1.7.0 and higher - a fast, small, and feature-rich JavaScript library;
  • Strophe.js - v. 1.2.6 and higher - an XMPP library for JavaScript. Its primary purpose is to enable web-based, real-time XMPP applications that run in any browser;
  • ydn-db - v. 0.9.2 and higher - Javascript database library for IndexedDB, WebSQL and WebStorage;
  • catapush - v. 0.1 and higher - Main Catapush Library;
  • catapush jquery widget - v. 0.1 and higher - Catapush jQuery Widget.

Can also been installed using npm (package.json):

..
  "dependencies": {
    "jquery": "*",
    "strophe.js": "*",
    "ydn.db": "*",
    "catapush": "*",
    "catapush_widget": "*"
  },
..

Catapush Widget is not mandatory, but represents an easy way to show messages.

Some cordova packages are also needed:

Full Example

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago