Phonegap CLI

This guide shows how to make a Cordova/PhoneGap application (android, iOS and windows phone) supporting Puship push notifications through the Command Line Interface platform.
Before creating the application, it is necessary to have configured correctly the CLI with the SDK of the platforms that have to be supported (a guide for cordova at this link, for phonegap at this link). Otherwise you can use the online build following the guide present on the PhoneGap Online Build page

  1. Browse to the directory where the source code has to be stored and run the following command to create the project:
cordova create puship com.puship.example Puship
//The first parameter (puship) defines the project folder name
//The second parameter (com.puship.example) defines the project package
//The third parameter (Puship) defines the Application’s name
  1. Go to the folder that has just been created and run the following commands to install the needed plug-ins:
cordova plugin add puship-plugin
  1. Add the following code in the receivedEvent method present in the js/index.js file:
onDeviceReady: function() {
	push = PushNotification.init({
		android: {
		browser: {
			pushServiceURL: ''
		ios: {
			alert: 'true',
			badge: 'true',
			sound: 'true'
		windows: {}20
	push.on('registration', (data) => {
		Puship.Register(data.registrationId, 'YOUR-PUSHIP-APP-CODE');

	push.on('notification', (data) => {
		// data.message,
		// data.title,
		// data.count,
		// data.sound,
		// data.image,
		// data.additionalData

	push.on('error', (e) => {
  1. Create a new application in the Puship Manager to get the Puship App ID and replace the value “YOUR-PUSHIP-APP-CODE” with it in the code above.
  2. Activate the needed notification service following the guide relative to the platform you are working on (Apple, Google Play or Microsoft Store).
  3. Could be necessary to enable the access to Puship server also in file index.html:
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
  1. Run the build command for add the platforms that is being supported:
cordova platform add android
//The platform parameter can be android or ios
  1. Run the build command for all platforms added:
cordova build
  1. To run the application
    • Android: Run the following command: cordova run android
    • iOS: Run the following command: cordova run ios
    • Windows Phone: Run the following command: cordova run windows

Once the application is running you should be able to see the “device registered”. Now you are able to connect to the Puship Manager and send push notification to your devices!

Pay attention:

  • Push notifications are not supported by the iOS emulator
  • Push notification are supported by the Android emulator but a particular and trickier setup is required so we suggest performing all the tests on an actual device.
  • If you want to add the push notification service to an existing project, start following the guide from the 2nd step

Below it’s available a video that explains how to create an application and activate push notifications with Puship

Download a complete example using the link below to better understand the whole process

Adding tags, geolocations management and all the other api are described in the guide common to all the platform that can be consulted at the following link: