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:
- Copy template files from our GitHub repository into your project.
- 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" />
- Run in-app rules in the appropriate points in your application.
MCEInAppPlugin.executeInAppRule(['test']);
Methods
(static) addInAppMessage (InApp)
addInAppMessage (InApp)
Adds an InAppMessage to the database, this is largely for testing purposes.
Parameter | Type | Description |
---|---|---|
InApp | Dictionary | Message dictionary |
(static) deleteInAppMessage (inAppMessageId)
deleteInAppMessage (inAppMessageId)
Allows Cordova InApp Plugin to delete an existing in-app message.
Parameter | Type | Description |
---|---|---|
inAppMessageId | Integer | The ID of the message to delete |
(static) executeInAppAction (action)
executeInAppAction (action)
Allows Cordova InApp Plugin to call out to action registry to handle rich message actions.
Parameter | Type | Description |
---|---|---|
action | Object | It 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)
executeInAppRule (rules)
Allows Cordova InApp Plugin to look for and possibly execute the next InApp message.
Parameter | Type | Description |
---|---|---|
rules | Array of string | A list of rules to match against |
(static) registerInAppTemplate (callback, templateName)
registerInAppTemplate (callback, templateName)
Allows Cordova InApp Plugin to register a template handler.
Parameter | Type | Description |
---|---|---|
callback | InAppTemplateCallback | The callback that handles the response |
templateName | String | A template name that this handler displays |
(static) syncInAppMessages ()
syncInAppMessages ()
Allows Cordova InApp Plugin to initiate a sync with the server.
Type definitions
InAppMessage
InAppMessage
Parameter | Type | Definition |
---|---|---|
content | Object | Template-defined details of the message |
expirationDate | Integer | Date the message should last appear in seconds since epoch |
inAppMessageId | String | The unique identifier of the InAppMessage |
maxViews | Integer | The total allowed number of views of the message. |
numViews | Integer | The current count of views of the message |
rules | Array of string | A list of rules to be matched against |
template | String | The template name that handles the message |
triggerDate | Integer | Date the message should first appear in seconds since epoch |
InAppTemplateCallback (inAppMessage)
InAppTemplateCallback (inAppMessage)
Parameter | Type | Description |
---|---|---|
inAppMessage | InAppMessage | The InApp message to display |
Related pages
Updated about 19 hours ago