remarkablelabs / phonegap

PushBots' official module for Phonegap

Home Page:http://pushbots.com/developer/docs/phonegap

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

phonegap

PushBots' official module for Phonegap

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

##Installation

cordova plugin add com.pushbots.push

##Usage

  1. Intialize Pushbots in deviceReady section:
onDeviceReady: function() {
	app.receivedEvent('deviceready');

	if( PushbotsPlugin.isiOS() ){
		PushbotsPlugin.initializeiOS("PUSHBOTS_APP_ID");
	}
	
	if( PushbotsPlugin.isAndroid() ){
		PushbotsPlugin.initializeAndroid("PUSHBOTS_APP_ID", "GCM_SENDER_ID");
	}
}
  1. Methods to use it:
//iOS && Android
//Set Alias
PushbotsPlugin.setAlias("alias");
//Tag Device
PushbotsPlugin.tag("tag");
//unTag device
PushbotsPlugin.untag("tag1");
//Enable debug mode
PushbotsPlugin.debug(true);
//Unregister device from Pushbots
PushbotsPlugin.unregister();
//Get device token
PushbotsPlugin.getToken(function(token){
	console.log(token);
});

//iOS only
//Reset Badge
PushbotsPlugin.resetBadge();
//Set badge
PushbotsPlugin.setBadge(10);
  1. To handle Notifications payload on Click [Android only]

Add this method to index.js

 function myMsgClickHandler(msg){
     console.log("Clicked On notification" + JSON.stringify(msg));
     alert(JSON.stringify(msg));
 }

Then set Notification click event:

PushbotsPlugin.onNotificationClick(myMsgClickHandler);

About

PushBots' official module for Phonegap

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


Languages

Language:Objective-C 52.1%Language:Java 32.6%Language:JavaScript 15.3%