surfyst / phonegap-1

PushBots' official module for Phonegap

Home Page:https://pushbots.com/developer/docs/phonegap-sdk-integration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

phonegap/Cordova Plugin for Pushbots

PushBots' official module for Phonegap/Cordova

https://pushbots.com/developer/docs/phonegap

Installation

This requires phonegap/cordova CLI 5.0+

cordova plugin add pushbots-cordova-plugin

##Usage

  1. Intialize Pushbots in deviceReady section:
var Pushbots = PushbotsPlugin.initialize("PUSHBOTS_APPLICATIONID", {"android":{"sender_id":"SENDER_ID"}});

// First time registration
// This will be called on token registration/refresh with Android and with every runtime with iOS
Pushbots.on("registered", function(token){
	console.log("Registration Id:" + token);
});

Pushbots.getRegistrationId(function(token){
	console.log("Registration Id:" + token);
});
  1. Methods to use it:
Pushbots.updateAlias("Test");
Pushbots.tag("tag1");
Pushbots.untag("tag1");
Pushbots.debug(true);
Pushbots.unregister();

//iOS only

//Reset Badge
Pushbots.resetBadge();
//Set badge
Pushbots.setBadge(10);
  1. To handle Notification events:
// Should be called once app receive the notification
Pushbots.on("notification:received", function(data){
	console.log("received:" + JSON.stringify(data));
});

// Should be called once the notification is clicked
// **important** Doesn't work with iOS while app is closed, will be fixed in 1.3.1
Pushbots.on("notification:clicked", function(data){
	console.log("clicked:" + JSON.stringify(data));
});

About

PushBots' official module for Phonegap

https://pushbots.com/developer/docs/phonegap-sdk-integration


Languages

Language:Objective-C 55.7%Language:Java 27.9%Language:JavaScript 16.4%