2.0.12 • Published 6 years ago

PushPlugin_V2 v2.0.12

Weekly downloads
12
License
ISC
Repository
github
Last release
6 years ago

Push Notifications Plugin V2 for Android, iOS and Windows


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!

2.0.12

6 years ago

2.0.11

6 years ago

2.0.10

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

8 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago