Our company is now using Unity 3D for a couple of major games in development and it became clear we wanted to benefit from this amazing work done by Pushwoosh team. It requires minimum efforts on our side and delivers functionality which is essential for most of the gaming projects.

Olga Zobova

Head of Mobile Games Publishing

Alawar Entertainment

READ TESTIMONIAL

PhoneGap/Cordova SDK

Download SDK Download Sample Plugin API Docs

1. Install the Plugin source code for Phonegap push notifications into your app by running the following command in the command line:

For Phonegap: phonegap plugin add https://github.com/Pushwoosh/pushwoosh-phonegap-3.0-plugin.git

For Cordova: cordova plugin add https://github.com/Pushwoosh/pushwoosh-phonegap-3.0-plugin.git

IMPORTANT: You also need to add cordova-plugin-whitelist plugin.
cordova plugin add cordova-plugin-whitelist

2. Whitelist *.pushwoosh.com domain in the config.xml file:

	<access origin="*.pushwoosh.com" />

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

function initPushwoosh()
{
	var pushNotification = cordova.require("com.pushwoosh.plugins.pushwoosh.PushNotification");

	//set push notifications handler
	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));
		}
									
		alert(title);
   	});

	//initialize Pushwoosh with projectid: "GOOGLE_PROJECT_NUMBER", pw_appid : "PUSHWOOSH_APP_ID". This will trigger all pending push notifications on start.
	pushNotification.onDeviceReady({ projectid: "GOOGLE_PROJECT_NUMBER", pw_appid : "PUSHWOOSH_APP_ID" });

	//register for pushes
	pushNotification.registerDevice(
		function(status) {
			var pushToken = status;
			console.warn('push token: ' + pushToken);
		},
		function(status) {
			console.warn(JSON.stringify(['failed to register ', status]));
		}
	);
}

In your onDeviceReady function add: initPushwoosh();

Example:

    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
    },
    // deviceready Event Handler
    //
    // The scope of 'this' is the event. In order to call the 'receivedEvent' function, we must explicitly call 'app.receivedEvent(...);'
    onDeviceReady: function() {
        app.receivedEvent('deviceready');
        initPushwoosh();
    },

4. 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));
	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.
Pushwoosh https://www.pushwoosh.com/wp-content/themes/pushwoosh/img/logo.png support@pushwoosh.com