2.1.0 • Published 2 years ago

puship-plugin v2.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
2 years ago

Puship Notifications Plugin for Android and iOS


DESCRIPTION

This plugin is for use with Puship.com, it's quickly enable support for Push Notifications on cordova and phonegap applications.

Is based on cordova-plugin-push, So, you can use all his methods for manage the push notifications. It and add only few resources for manage remote push notifications on Puship server(s): 1) one javascript library 2) many sounds 3) plugin dependencies: - cordova-plugin-device - cordova-plugin-geolocation - cordova-plugin-push

Important - Push notifications are intended for real devices. The registration process will fail on the iOS simulator. Notifications can be made to work on the Android Emulator, however doing so requires installation of some helper libraries.

Installation

Normally it is sufficient to add the plugin as indicated below, but if you have special needs you can first manually install the cordova-plugin-push and configure it as spelled at the following link, and then resume from here. Since the cordova-plugin-push is already installed it will not be installed again.

Cordova

The plugin can be installed via the Cordova command line interface:

1) Navigate to the root folder for your cordova project. 2) Run the command.

cordova plugin add https://github.com/Puship/PushPlugin.git

Phonegap

The plugin can be installed using the Phonegap command line interface:

1) Navigate to the root folder for your phonegap project. 2) Run the command.

phonegap local plugin add https://github.com/Puship/PushPlugin.git

Plugman

The plugin is based on plugman and can be installed using the Plugman command line interface:

plugman install --platform [PLATFORM] --project [TARGET-PATH] --plugin [PLUGIN-PATH]

where
	[PLATFORM] = ios or android
	[TARGET-PATH] = path to folder containing your phonegap project
	[PLUGIN-PATH] = path to folder containing this plugin

How to activate

Go to Puship.com and create your Free account. Configure your application from dashboard an then add highlighted code to your index.js:

#	function onDeviceReady() {
#        this.receivedEvent('deviceready');
#		
#		push = PushNotification.init({
#			android: {
#			},
#			browser: {
#				pushServiceURL: 'http://push.api.phonegap.com/v1/push'
#			},
#			ios: {
#				alert: "true",
#				badge: "true",
#				sound: "true"
#			},
#			windows: {}
#		});
#		
#		push.on('registration', (data) => {
+			var appCode = "YOUR-PUSHIP-APP-CODE"; // I.E.: puship_id = "h1mCVGaP9dtGnwG"
+			Puship.Register(data.registrationId, appCode);
#		});
#
#		push.on('notification', (data) => {
+			alert(JSON.stringify(data));
#			// data.message,
#			// data.title,
#			// data.count,
#			// data.sound,
#			// data.image,
#			// data.additionalData
#		});
#
#		push.on('error', (e) => {
#			alert(e.message);
#		});
#		
#		document.getElementById('deviceready').classList.add('ready');
#		console.log('Running cordova-' + cordova.platformId + '@' + cordova.version);
#    }

Then run your app and start send push notifications!

...and yes, this is lovely all!

Other tips

1) at this link you can find a complete example that use all library methods 2) a this link you can find official library documentation