In-app message plugin for Cordova apps

The In-app message plugin lets you add InApp functionality to your application. The messages are created on the server and passed to the device over a periodic synchronization process. These messages are displayed over the application content, typically as promotional messages.

The messages are displayed via templates that define how they look and if they cover the entire screen or only a part of the screen. The default templates we provide are customizable. You can also create your own InApp templates to provide for additional use cases.

Getting started

The In-app message plugin is added to the Campaign library by default. If you open the plugins section of CampaignConfig.json (the primary configuration file for the Campaign library), you will find the following entry for it.

"cordova-acoustic-mobile-push-plugin-inapp": true,

Here is a sample CampaignConfig.json for your reference.

To start using the In-app message plugin, do the following:

  1. Copy template files from our GitHub repository into your project.
  2. Add the default in-app template stylesheet to the page. This includes support for additional plugins, such as videos and images.
<link rel="stylesheet" type="text/css" href="css/inapp_media.css" />
<link rel="stylesheet" type="text/css" href="css/inapp_banner.css" />
<link rel="stylesheet" type="text/css" href="css/inapp_image.css" />
<link rel="stylesheet" type="text/css" href="css/inapp_video.css" />
  1. Run in-app rules in the appropriate points in your application.
MCEInAppPlugin.executeInAppRule(['test']);

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

Related pages