Tuesday, August 25, 2015

PhoneGap-Plugin-Push Version 1.2.0 Released!

The latest release of the PushPlugin is now available on npm. This release focuses on bringing a number of enhancements to Android notifications.

Fear not fans of other platforms as subsequent releases will have more features for your OS of choice. In fact release 1.3.0 will center around iOS9 support.

Picture Notifications

Embed a large picture in your notification. You let the plugin know you want to display a picture by setting the style of the push to picture and then giving it a picture property.

For example:
{
    title:"Big Picture", 
    message: "This is my big picture message", 
    style: "picture",
    picture: "http://36.media.tumblr.com/c066cc2238103856c9ac506faa6f3bc2/tumblr_nmstmqtuo81tssmyno1_1280.jpg",
    summaryText: "The internet is built on cat pictures"
}
Produces the cat picture on the right.

Inbox Notifications

Instead of stacking notifications in the tray you can now add multiple notifications to a single entry in the tray by setting the style to inbox. The first notification that arrives looks like normal but the subsequent ones will look like an inbox.

For example:
{
    title:"My Title", 
    message: "My first message", 
    style: "inbox",
    summaryText: "There are %n% notifications"
}
Followed by:
{
    title:"My Title", 
    message: "My second message", 
    style: "inbox",
    summaryText: "There are %n% notifications"
}
Produces the notification above.

Finally, my favourite new addition...

Action Buttons

Your notification can include action buttons. If you wish to include an icon along with the button name they must be placed in the res/drawable directory of your Android project. Then you can send the following JSON from GCM:
{
    title:"AUX Scrum", 
    message: "Scrum: Daily touchbase @ 10am Please be on time so we can cover everything on the agenda.", 
    actions: [
        { icon: "emailGuests", title: "EMAIL GUESTS", callback: "app.emailGuests"},
        { icon: "snooze", title: "SNOOZE", callback: "app.snooze"},
    ]
}
This will produce the following notification in your tray:


When the user clicks on one of the buttons it will execute the JavaScript code you specified as a callback for that button.

Check out the plugin's README for more details.

Full Change Log
1.2.0 (2015-08-25)

Implemented enhancements:
  • Implement Big Picture Style for Android #75
  • Implement Inbox style for Android #74
  • on("registration" is not getting called... #66
  • multi-line text support #63
  • Add image property to iOS and Android #39
  • Programmatically register #31
Fixed bugs:
  • Pushes being deleted from notification bar when cold start #67
  • No default sound in Android #53
  • Multiple push notification problem #48
Closed issues:
  • oficial push plugin and windows and wp8 compatibility #71
  • On Android, GCMIntentService.onError() doesn't get passed to the JavaScript "error" event #65
  • Android: add property to vibrate phone on received notification #61
  • push.on => "registration" will trigger twice times that only in iOS #57
  • Publish plugin to PhoneGap Build #22
Merged pull requests:

2 comments:

  1. Hi Simon,

    Thanks for the great plugin, we were able to integrate GCM in no time. However, we were not able to figure out integrating APNS into our app. The Github page for your plugin has no documentation related to iOS except for custom sound. Can you help us on this?

    Thanks,
    Naveen.

    ReplyDelete
  2. @Naveen Santosh Sanapathi that is because there is nothing special to do on the Apple side. As long as you have your provisioning profile and certificate (with push enabled) setup the app will build and run with push support. The first time you call init it will ask to allow push.

    ReplyDelete