Add the plugin to an Android Cordova project

Overview

The CONTXTFUL plugin includes the CONTXTFUL SDK any Android build of a Apache Cordova project.

Adding to a Cordova project

  1. Unzip the cordova-plugin-contxtful.zip file.

  2. Put the cordova-plugin-contxtful/ folder and android.json in the plugins/ folder of your project.

  3. Edit android.json, replace PACKAGE_NAME with id of the application found in the config.xml file of the project.

Connecting the plugin to the Activity

Modify the main index.js file under www/js/ like this :

function onSuccess(str){ // Your code here! } function onError(ErrStr){ // Your code here! } var app = { // Application Constructor initialize: function() { navigator.ContxtfulManager.start(onSuccess, onError); }, }; app.initialize();

Running the project

Run the following command in a terminal in your project

sudo rm -r platforms/ sudo cordova platform add android sudo chown -R $USER:$USER platforms/ cordova build android cordova run android

Or follow your preferred project building process!

Note : The current version of the CONTXTFUL plugin for Apache Cordova only supports Android.