The Cocoon Parse Push Notifications plugin is a Cordova plugin aimed at providing easy integration with  the Parse Push notifications service.

Installation

To add the Parse Push notifications plugin to your project first go to your project configuration and once there go to the Setting  section and click on the “Plugins” tab. You should see something like this:

New Cocoon

If you click on the “Cocoon” category you will see al the Cocoon available plugins.  Over the plugins list you will see a dropdown menu set to “All” by default. Click on the menu to see the available Cocoon plugins categories, you should see a list of plugins with at least the following groups:

Screen Shot 2016-01-05 at 16.40.33

Select the “Notifications” plugin. Then the Notifications related plugins should be filtered in the plugins list.

Screen Shot 2016-01-13 at 16.48.47

Now click on install and your project will include the Parse Push Notifications plugin in the next compilation.

Screen Shot 2016-01-13 at 16.49.22

 

Parameters

Getting the parameters

You need to get the application Id from the Parse project site.

First you need to have a Parse application created. Once the app is created you should see it in the Parse dashboard:

Screen Shot 2016-01-13 at 16.52.10

Click on the app and the application settings will show. Go to “App settings” -> “Security and keys

Screen Shot 2016-01-13 at 16.55.12

Copy the “Application ID” and “Client key” keys, you will need them to configure the plugin.

Setting up the parameters

Using the Cocoon Plugins interface

You can setup the “Application ID” and “Client key” using the Cocoon cloud plugins interface. After installing the Parse Push Notifications plugin you will see an “Add Parameter” button under the plugin details:

Screen Shot 2016-01-13 at 16.59.09

Click on that button and you will see two fields for adding a name and a value. You need to add the following parameters:

  • APP_ID: The Parse application id
  • CLIENT_KEY: The Parse client key

Screen Shot 2016-01-13 at 17.01.46

Integration

Cordova needs to be specifically loaded in your index.html so it can start the Cordova framework and load the plugins that you have installed in your project. So first thing is to add the “cordova.js” script tag to your index.html.

That’s the only code script you need to include in your index.html for the plugin to be ready to be used. Cordova will do the rest.

Important: Remember to wait for the “deviceready” event before using the plugin as that is the moment when the plugin will be fully initialized.

Usage

Let’s see some code snippets showing how to use the Cocoon Parse Push notifications plugin in your application.

Initialization

Starts the Notification Service. The notification callbacks will start to be received after calling this method. Because of this, you should have set your event handler before calling this method, so you won’t lose any callback.
The service will be automatically registered after the initialization. This may show a Dialog to request user permissions. You can disable autoregister with {register: false} params and call Cocoon.Notification.Local.register() manually to control when the permissions dialog is shown. By default the register parameter is set to true.

Listening for notifications

Subscribing to a channel

Sending a local notification

Other Local notifications API methods

Please see the full API below and the example for more Parse Push notifications API methods.

Example

exmaple_button

API

api_button

Testing

To test your push notifications plugin integration:

  1. Install the Parse Push Notification plugin in your project
  2. Compile a Developer App
  3. Launch you app from the Developer App using a zip or a url options