Skip to content

Push Notification Plugin integrated with Puship.com service

Notifications You must be signed in to change notification settings

Puship/PushPlugin_V2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[DEPRECATED] Push Notifications Plugin V2 for Android, iOS and Windows

This plugin is deprecated, i.e. it is no longer maintained. Going forward additional features and bug fixes will be added to the new puship-plugin repository.


DESCRIPTION

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

This plugin extends the plugin phonegap-plugin-push, So, you can use all his methods for manage the push notifications

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.

##Automatic Installation

Note: For each service supported - APNS, GCM or MPNS - you may need to download the SDK and other support files.

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 PushPlugin_V2 --variable SENDER_ID="XXXXXXX"

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 PushPlugin_V2 --variable SENDER_ID="XXXXXXX"

Where the XXXXXXX in SENDER_ID="XXXXXXX" maps to the project number in the Google Developer Console. To find the project number login to the Google Developer Console, select your project and click the menu item in the screen shot below to display your project number.

zzns8

If you are not creating an Android application you can put in anything for this value.

Note: if you are using ionic you may need to specify the SENDER_ID variable in your package.json.

  "cordovaPlugins": [
    {
      "variables": {
        "SENDER_ID": "XXXXXXX"
      },
      "locator": "PushPlugin_V2"
    }
  ]

Note: You need to specify the SENDER_ID variable in your config.xml if you plan on installing/restoring plugins using the prepare method. The prepare method will skip installing the plugin otherwise.

<plugin name="PushPlugin_V2">
    <variable name="SENDER_ID" value="XXXXXXX" />
</plugin>

##How to use:

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

receivedEvent: function(id) {
        var parentElement = document.getElementById(id);
        var listeningElement = parentElement.querySelector('.listening');
        var receivedElement = parentElement.querySelector('.received');
		
        listeningElement.setAttribute('style', 'display:none;');
        receivedElement.setAttribute('style', 'display:block;');

        console.log('Received Event: ' + id);
		
		
		var Puship = puship.init();
		Puship.PushipAppId="z23KUaPqVU7MbUq"; //Your AppId generated on Puship Dashboard
		Puship.EnableLog=true;
		
	
 		var push = PushNotification.init({
			android: {
				senderID: "XXXXXXX" 
			},
			ios: {
				alert: "true",
				badge: true,
				sound: 'false'
			},
			windows: {}
		});
		
		push.on('registration', function(data) {

			Puship.Common.Register(data.registrationId,
			{
				successCallback: function (pushipresult){
					navigator.notification.alert("device registered with DeviceId:" + pushipresult.DeviceId);
				},
				failCallback: function (pushipresult){
					navigator.notification.alert("error during registration: "+ JSON.stringify(pushipresult));
				}
			});
		});
		
		push.on('notification', function(data) {
			
			navigator.notification.alert("PUSH: " + JSON.stringify(data));
			// data.title,
			// data.count,
			// data.sound,
			// data.image,
			// data.additionalData
		});
	}

Then run your app and start send push notifications!

...and yes, this is lovely all!

About

Push Notification Plugin integrated with Puship.com service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published