If you are going to be at any of those events please introduce yourself to me so we can chat. Other than that I'll have limited time available in those two cities but I do love coffee so hit me up on twitter.

Now I'm in favour of anything that makes my life easier so I decided to take np and enhance it with some tasks I routinely do when publishing new plugins. My first pass at it is a new package called pluginpub which is a copy of np that I eventually hope to change to depend on np instead.

The main difference is that it:

Bumps the version in plugin.xml, package.json and npm-shrinkwrap.json (if present) and creates a git tag

It now automates a lot of stuff I used to do manually into a single command. Installation is simple, you run:

npm install pluginpub --save-dev

In the root of your plugin repo. Then to release a new version of the plugin you would execute the command from the root of your plugin repo:

pluginpub 1.5.8

The command takes only one argument and that is the version of the plugin. If you don't pass in a valid semver then the command will fail.

Anyway, it make or may not be of use to you. Feel free to try it out and report any issues on the github page. Next steps are publishing a proper README and adding the auto-generation of a CHANGELOG file which is another manual step I hate doing when releasing a plugin.

Monday, June 27, 2016

Everyone loves the new hotness of ES2015 features but sadly not all of the devices your app is going to run on are able to take advantage of all the features of ES2015. Luckily we can use Babel to transpile our ES2015 code into ES5 code that will run everywhere. This way we can write our plugin's JS using the new hotness but still run everywhere.

I've started working on a version of the PhoneGap Push Plugin in the es6 branch that uses ES2015 and what follows is a description of how I set it up.

Step 1: Add the necessary packages to package.json

We need to add Babel to our package.json so open the file and add the following lines.

We'll have to tell babel how we want the code transpiled from ES2015 to ES5. So create a new file called .babelrc in the root of your plugin project and populate it with the following lines:

{
"presets": [
"es2015"
]
}

Step 3: Write your ES2015 code

I like to add a new directory under the src folder called src/js. It is in this folder that I like to keep my ES2015 compliant code.

Step 4: Transpile your code

Once your ES2015 code is written it is time to transpile it to ES2015 so you can publish to NPM and Github. For this open package.json and add a new line to the scripts section:

"scripts": {
"build": "babel src/js --out-dir www",
}

Now if you run the command:

npm run build

You will find your transpiled code in the www folder of your plugin.

Step 5: Link to the ES5 code in plugin.xml

It is key that you don't actually deliver the ES2015 code as part of the plugin as you want to make sure your users are executing the ES5 version. To do that open plugin.xml and make sure that your js-module tag refers to code in the www directory like:

Bonus Material
If you are anything like me, writing ES2015 code is not quite second nature yet. In order to help me along I setup my project to be linted automatically.Step 1: Add the necessary packages to package.json

We need to add ESLint to our package.json so open the file and add the following lines.

Not sure what editor you are using to write JS but I'm using Atom at the moment so I have installed the linter-eslint package which automatically picks up my .eslintrc file and lints my code on the fly.

Sunday, May 22, 2016

Late last week Google pushed a new version of Google Play Services out to phones and since them some users of the phonegap-plugin-push have been seeing crashes in their app. The stack trace for that crash looks like this:

The crash is being cause because of a incompatibility between the newly released Google Play Services and Android Support Library v4. The phonegap-plugin-push does not use Android Support Library v4 but another plugin in your app may. You can check by doing:

grep -r com.android.support plugins

To see which other plugin is using Android Support Library v4. Removing that plugin, recompile and reinstall the application fixes the problem. Obviously this is not a desired or long term fix. Trying to figure out a way to prevent this but I fear we will require a new version of Android Support Library v4 from Google.

Subscribe to the Issue #909 on the plugin's repo for more info and updates.

You can see the commands in action in this terminal session recording:

To create my own set of magic commands for Cordova. You can grab the additions I put into my .bash_profile file from this gist.
There is no real good reason for this other than I giggle to myself everytime I enchant or curse a plugin.

Tuesday, October 27, 2015

The latest release of the PushPlugin is now available on npm. This release is the long awaited release that is fully tested with iOS9. I was able to test on an iPhone 6+ running iOS 8.4.1, iPod Touch running iOS 9.0.2 and an iPad Air 2 running iOS 9.1.0. Please let me know if you run into any problems with this release.

On Android the switch over to using Gradle is now complete. The deprecated gcm.jar has been removed from the plugin and replaced with the Google Play Services GCM framework. Even better news is that PhoneGap Build now supports Gradle builds.

The big feature that people have been clamoring for is background or silent notifications. It is now possible for your 'notification' event handler to run when you app is in the background on iOS and Android (support for Windows coming soon).

Monday, September 21, 2015

The latest release of the PushPlugin is now available on npm. This release switches the plugin over to using Gradle to include the Android Support Framework jar instead of it being included in the plugin. This should fix the issue where this plugin would conflict with others, like the Facebook plugin when building. Just make sure you have version 23 or later of the Android Support Library which can be installed from the Android SDK Manager.

Unfortunately, PhoneGap Build does not yet support Gradle so if you are using this plugin with PhoneGap Build you will need to use version 1.2.3 or earlier for the time being.

I know last time I said I would be making sure that iOS9 works with version 1.3.0 but I wanted to get that Gradle change out as quick as I could. Next release 1.4.0 will be full tested with iOS9 and I won't wait a full month, I'll release it just as soon as it's tested.

Hello, i am developing a cordova app which requires push notifications to be sent to users android phone, so i tried using this new phonegap push plugin as old one is deprecated, and it keeps giving me an error in console: Uncaught ReferenceError: module is not defined --- Line 154 Push.js and i dont have much experience with cordova, so can anyone assist me ? #128