Pushwoosh is just the solution we were looking for. What can I say, it does exactly what it says in the tin. It dropped straight into our game with no effort and now our game users send and receive notifications to and from each other. From HQ, we are also able send notifications to targeted users or groups of users.

It's really brought our game alive and improved retention enormously.

Kevin Cook

Programming Director

PixelFlip Media Ltd.

READ TESTIMONIAL

PhoneGap/Cordova SDK

Download SDK Sample Project

1. Install the Plugin source code for Phonegap push notifications into your app by running the following command in the command line: phonegap local plugin add https://github.com/shaders/pushwoosh-phonegap-build-plugin.git

2. Add the PushNotification.js from the www folder to your www folder on disk.

3. Add the reference to the PushNotification.js file using <script> tags in your html file(s):

    <script type="text/javascript" src="PushNotification.js"></script>

4. Add new entry to your “config.xml” (in the www folder)

<cordova>
    <access origin="https://cp.pushwoosh.com" subdomains="true" />

5. Register for push notifications: Add the following function to your javascript file, enter the correct Project Number and Pushwoosh App ID

function initPushwoosh()
{
	var pushNotification = window.plugins.pushNotification;
	pushNotification.onDeviceReady();

	pushNotification.registerDevice({ projectid: "GOOGLE_PROJECT_ID", appid : "PUSHWOOSH_APP_ID" },
		function(status) {
			var pushToken = status;
			console.warn('push token: ' + pushToken);
		},
		function(status) {
			console.warn(JSON.stringify(['failed to register ', status]));
		}
	);

	document.addEventListener('push-notification', function(event) {
		var title = event.notification.title;
	        var userData = event.notification.userdata;
	                            
	        if(typeof(userData) != "undefined") {
			console.warn('user data: ' + JSON.stringify(userData));
		}
									
		navigator.notification.alert(title);
	});
}

Add method init() to the onload function in HTML:

<body onload="init();" >

In the init function add:

function init() {
    document.addEventListener("deviceready", initPushwoosh, true);

    //rest of the code
}

6. Receiving push notifications. See the following snippet of code in initPushwoosh function

	document.addEventListener('push-notification', function(event) {
	 	var title = event.notification.title;
	        var userData = event.notification.userdata;

		console.warn('user data: ' + JSON.stringify(userData));
		navigator.notification.alert(title);
});
Due to compatibility with Android 4 please make sure you are using at least 11 version of the Android API.
The SDK will run on older devices.

Push Notifications SDK API:

	// Call this to register for push notifications and retreive a deviceToken
	PushNotification.prototype.registerDevice = function(config, success, fail) {
		cordova.exec(success, fail, "PushNotification", "registerDevice", config ? [config] : []);
	};

	// Call this to set tags for the device
	PushNotification.prototype.setTags = function(config, success, fail) {
		cordova.exec(success, fail, "PushNotification", "setTags", config ? [config] : []);
	};

	//Unregister device from push notifications
	PushNotification.prototype.unregisterDevice = function(success, fail) {
		cordova.exec(success, fail, "PushNotification", "unregisterDevice", []);
	};

	//starts geo push notifications
	PushNotification.prototype.startGeoPushes = function(success, fail) {
		cordova.exec(success, fail, "PushNotification", "startGeoPushes", []);
	};

	//stops geo push notifications
	PushNotification.prototype.stopGeoPushes = function(success, fail) {
		cordova.exec(success, fail, "PushNotification", "stopGeoPushes", []);
	};

	//sets multi notification mode on
	PushNotification.prototype.setMultiNotificationMode = function(success, fail) {
		cordova.exec(success, fail, "PushNotification", "setMultiNotificationMode", []);
	};
	
	//sets single notification mode
	PushNotification.prototype.setSingleNotificationMode = function(success, fail) {
		cordova.exec(success, fail, "PushNotification", "setSingleNotificationMode", []);
	};

	//type: 0 default, 1 no sound, 2 always
	PushNotification.prototype.setSoundType = function(type, success, fail) {
		cordova.exec(success, fail, "PushNotification", "setSoundType", [type]);
	};	

	//type: 0 default, 1 no vibration, 2 always
	PushNotification.prototype.setVibrateType = function(type, success, fail) {
		cordova.exec(success, fail, "PushNotification", "setVibrateType", [type]);
	};