The Cocoon Local Notifications plugin is a Cordova plugin aimed at providing easy integration with  the platform’s Local Notifications API.

Installation

To add the Local 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 15.45.07

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

Screen Shot 2016-01-13 at 15.45.51

 

Parameters

This plugin doesn’t need initialization parameters.

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 Local 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

Sending a local notification

Other Local notifications API methods

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

Example

exmaple_button

API

api_button

Testing

To test your Local notifications plugin integration:

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