Notification action plugins for Cordova apps

The Campaign library supports several notification action plugins. The primary plugins are added by default. You can install additional ones during the library integration or any time later.

Prerequisites

To use the plugins, you must integrate the Campaign library into your app.

Installation

  1. In the root directory of your project, open the CampaignConfig.json file. Here is an example from our sample app.
  2. In the plugins section, set the plugins you need to true.
{
  "plugins": {
    "Please note": "<true/false>, for cordova build.  True for release build, false for beta build",
    "useRelease": false,
    
    "Required Mobile-Push plugins": "<true/false>, enable or disable plugin",
    "cordova-acoustic-mobile-push": true,
    "cordova-acoustic-mobile-push-plugin-ios-notification-service": true,
    "cordova-acoustic-mobile-push-plugin-inapp": true,
    "cordova-acoustic-mobile-push-plugin-inbox": true,
    
    "Optional Mobile-Push plugins": "<true/false>, enable or disable plugin",
    "cordova-acoustic-mobile-push-plugin-action-menu": false,
    "cordova-acoustic-mobile-push-plugin-beacon": false,
    "cordova-acoustic-mobile-push-plugin-calendar": false,
    "cordova-acoustic-mobile-push-plugin-displayweb": false,
    "cordova-acoustic-mobile-push-plugin-geofence": false,
    "cordova-acoustic-mobile-push-plugin-location": false,
    "cordova-acoustic-mobile-push-plugin-passbook": false,
    "cordova-acoustic-mobile-push-plugin-snooze": false
  }
}
  1. Important: to apply the changes, run the following Node.js command from the root project directory.
node node_modules/cordova-acoustic-mobile-push/scripts/installPlugins.js

In-app message plugin API reference

Below are the methods that you can use to manage in-app notifications in the Campaign library for Cordova.

Methods

(static) addInAppMessage (InApp)

Adds an InAppMessage to the database, this is largely for testing purposes.

ParameterTypeDescription
InAppDictionaryMessage dictionary

(static) deleteInAppMessage (inAppMessageId)

Allows Cordova InApp Plugin to delete an existing in-app message.

ParameterTypeDescription
inAppMessageIdIntegerThe ID of the message to delete

(static) executeInAppAction (action)

Allows Cordova InApp Plugin to call out to action registry to handle rich message actions.

ParameterTypeDescription
actionObjectIt is normally in the format {"type": <type>, "value": <value> }, but can be anything that is sent in the "notification-action" or the "category-actions" section of the payload.

(static) executeInAppRule (rules)

Allows Cordova InApp Plugin to look for and possibly execute the next InApp message.

ParameterTypeDescription
rulesArray of stringA list of rules to match against

(static) registerInAppTemplate (callback, templateName)

Allows Cordova InApp Plugin to register a template handler.

ParameterTypeDescription
callbackInAppTemplateCallbackThe callback that handles the response
templateNameStringA template name that this handler displays

(static) syncInAppMessages ()

Allows Cordova InApp Plugin to initiate a sync with the server.

Type definitions

InAppMessage

ParameterTypeDefinition
contentObjectTemplate-defined details of the message
expirationDateIntegerDate the message should last appear in seconds since epoch
inAppMessageIdStringThe unique identifier of the InAppMessage
maxViewsIntegerThe total allowed number of views of the message.
numViewsIntegerThe current count of views of the message
rulesArray of stringA list of rules to be matched against
templateStringThe template name that handles the message
triggerDateIntegerDate the message should first appear in seconds since epoch

InAppTemplateCallback (inAppMessage)

ParameterTypeDescription
inAppMessageInAppMessageThe InApp message to display

Inbox notification plugin API reference

Below are the methods that you can use to manage inbox notifications in the Campaign library for Cordova.

Methods

(static) clearExpiredMessages()

Allows Cordova Inbox Plugin to immediately remove expired messages from the inbox database.

(static) deleteMessageId(inboxMessageId)

Allows Cordova Inbox Plugin to delete a message from the database cache and server.

ParameterTypeDefinition
inboxMessageIdStringA unique identifier for an inbox message

(static) executeInboxAction(action)

Allows Cordova Inbox Plugin to call out to action registry to handle rich message actions.

ParameterTypeDefinition
actionObjectIt is normally in the format {"type": <type>, "value": <value>}, but can be anything that is sent in the "notification-action" or the "category-actions" section of the payload.

(static) fetchInboxMessageId(inboxMessageId, callback)

Allows Cordova Inbox Plugin to get the inbox message by providing the inbox message ID.

ParameterTypeDefinition
inboxMessageIdStringA unique identifier for an inbox message
callbackinboxMessageCallbackThe callback that handles the response

(static) fetchInboxMessageViaRichContentId(richContentId, callback)

Allows Cordova Inbox Plugin to retrieve an inbox message by providing a richContentId.

ParameterTypeDefinition
richContentIdStringUnique identifier for rich content
callbackinboxMessageCallbackThe callback that handles the response

(static) readMessageId(inboxMessageId)

Allows Cordova Inbox Plugin to set the read status of a message in the database cache and server.

ParameterTypeDefinition
inboxMessageIdStringUnique identifier for inbox message

(static) setInboxMessagesUpdateCallback(callback)

Allow Cordova Inbox Plugin to respond to changes in the inbox list.

ParameterTypeDefinition
callbackinboxListCallbackThe callback that handles the response

(static) syncInboxMessages()

Allows Cordova Inbox Plugin to initiate a sync with the server. Will execute function registered with setInboxMessagesUpdateCallback when complete.

Type definitions

inboxListCallback(messages)

ParameterTypeDefinition
messagesArrayMessages in Inbox

InboxMessage

ParameterTypeDefinition
attributionStringCampaign name message was sent with
expirationDateIntegerExpiration of message in seconds since epoch
inboxMessageIdStringUnique identifier for inbox message
isDeletedBooleantrue for message deleted, false for message not deleted
isReadBooleantrue for message read, false for message unread
richContentIdStringUnique identifier for rich content
sendDateIntegerMessage sent date in seconds since epoch
templateStringTemplate name that handles display of this message

inboxMessageCallback(messages)

ParameterTypeDefinition
messagesInboxMessageInbox message content

Location plugin API reference

Methods

(static) locationAuthorization()

This method reports if the app has authorization to use location services. It can report the following values:

  • -2 - the app has foreground only access to location services (use the manualLocationInitialization method)
  • -1 - the app is not authorized to use location services
  • 0 - the app has not yet requested to use location services (use the manualLocationInitialization method)
  • 1 - the app has complete access to location services

(static) manualLocationInitialization()

Use this method to manually initialize location services for the Campaign library. This lets you delay location services initialization until desired.

To enable the method, you must set the Auto initialize location feature to false in the CampaignConfig.json file.

(static) setLocationAuthorizationCallback()

This callback is called when access to the location services changes.

(static) setLocationUpdatedCallback(callback)

Set callback for location database updates.

ParameterTypeDefinition
callbacklocationCallbackCallback which will be called when the database is updated.

(static) syncLocations()

Prompts the Campaign library to synchronize the geofences with the server. This can only be called once every 5 minutes.

Type definitions

locationCallback

The location callback includes no data. When it is received you should refresh your inbox database.

Beacon plugin API reference

Methods

(static) beaconEnabled(callback)

Query if iBeacons are enabled or disabled.

ParameterTypeDefinition
callbackbeaconEnabledCallbackResponse callback

(static) beaconRegions(callback)

Query the current iBeacon regions.

ParameterTypeDefinition
callbackbeaconRegionsCallbackThe callback with the current iBeacon regions.

(static) beaconUUID(callback)

Query if iBeacon global UUID currently setup.

ParameterTypeDefinition
callbackbeaconUUIDCallbackResponse callback.

(static) setBeaconEnterCallback(callback)

Set callback for entering iBeacon regions.

ParameterTypeDefinition
callbackbeaconCallbackCallback function for entering iBeacon regions.

(static) setBeaconExitCallback(callback)

Set callback for exiting iBeacon regions.

ParameterTypeDefinition
callbackbeaconCallbackCallback function for exiting iBeacon regions.

Type definitions

Beacon

PropertyTypeDefinition
majorIntegerMajor of beacon region
minorIntegerMinor of beacon region
locationIdStringIdentifier of beacon region

beaconCallback(beacon)

PropertyTypeDefinition
beaconBeaconBeacon region entered or left.

beaconEnabledCallback(status)

PropertyTypeDefinition
statusBooleantrue if iBeacons are enabled, false otherwise.

BeaconMajor

PropertyTypeDefinition
majorIntegerMajor of beacon region

beaconRegionsCallback(beacons)

PropertyTypeDefinition
beaconsArrayList of current beacon regions.

beaconUUIDCallback(status)

PropertyTypeDefinition
statusStringBeacon global UUID setup.

Geofence plugin API reference

Methods

(static) geofenceEnabled(callback)

Query if geofences are enabled or disabled.

ParameterTypeDefinition
callbackgeofenceEnabledCallbackResponse callback.

(static) geofencesNear(callback, latitude, longitude, radius)

ParameterTypeDefinition
callbackgeofencesNearCallbackCallback data will be provided to
latitudedoubleLatitude of center of area
longitudedoubleLongitude of center of area
radiusdoubleRadius of area

(static) setGeofenceEnterCallback(callback)

Set callback for entering geofences.

ParameterTypeDefinition
callbackgeofenceCallbackCallback executed when geofences are entered.

(static) setGeofenceExitCallback(callback)

Set callback for exiting geofences.

ParameterTypeDefinition
callbackgeofenceCallbackCallback executed when geofences are exited.

Type definitions

Geofence

PropertyTypeDefinition
latitudedoubleLatitude of center of geofence.
longitudedoubleLongitude of center of geofence.
radiusdoubleRadius of geofence in meters.
locationIdStringUnique location identifier.

geofenceCallback(geofence)

PropertyTypeDefinition
geofenceGeofenceGeofence entered or exited.

geofenceEnabledCallback(status)

PropertyTypeDefinition
statusbooleantrue if geofences are enabled, false otherwise.

geofencesNearCallback(geofences)

PropertyTypeDefinition
geofencesArrayList of geofences