Initial SDK Setup

Download the SDK from github and run cordova plugin add path_to_repo/plugin/ from the root your project.

Alternatively, you could install directly from github, like cordova plugin add https://github.com/appboy/appboy-cordova-sdk#master:/plugin/

Configure the plugin

In your config.xml, add a preference element under the android platform element that contains your Appboy API key with the name com.appboy.api_key:

    <platform name="android">
        <preference name="com.appboy.api_key" value="YOUR_API_KEY" />
        ...
    </platform>

The Cordova Android SDK also allows for various other settings to be configured via the config.xml file:

    <platform name="android">
        <preference name="com.appboy.android_automatic_push_registration_enabled" value="true"/"false" />
        <preference name="com.appboy.android_gcm_sender_id" value="YOUR_GCM_SENDER_ID" />
        <preference name="com.appboy.android_small_notification_icon" value="RESOURCE_ENTRY_NAME_FOR_ICON_DRAWABLE" />
        <preference name="com.appboy.android_large_notification_icon" value="RESOURCE_ENTRY_NAME_FOR_ICON_DRAWABLE" />
        <preference name="com.appboy.android_notification_accent_color" value=ACCENT_COLOR_INTEGER />
        <preference name="com.appboy.android_default_session_timeout" value=SESSION_TIMEOUT_INTEGER />
        <preference name="com.appboy.android_handle_push_deep_links_automatically" value="true"/"false" />
        <preference name="com.appboy.android_log_level" value=LOG_LEVEL_INTEGER />
    </platform>

See the AppboyConfig.Builder javadoc for more details.

Customized Setup

Note that this plugin can be forked and modified for custom implementations. Find the platform-specific native source code in the /plugin/src directory, the javascript interface in the /plugin/www directory, and the main configuration file at /plugin.

Users that check their platform directory into version control (enabling them to make permanent code edits there) will be able to further leverage Appboy’s UI elements by calling them directly from their platform specific project.

Removing automatic push setup (Android)

To remove automatic push registration on Android, set the com.appboy.android_automatic_push_registration_enabled value in the plugin config.xml to false.

Initial Setup Complete

Once the initial setup is complete, you can access the AppboyPlugin javascript interface in your app.

Push Notifications

If you use the Cordova SDK default setup you won’t have to make any new changes client-side. For modified integrations, see the Android integration instructions.

In-App Messaging

By default the Cordova SDK supports in-app messages with no changes. See the Android integration instructions for information on customizing in-app messages. Furthermore, you can look at the sample Cordova application or the sample Android application for implementation samples.

Analytics

Setting User IDs

See the Android integration instructions for an in depth discussion of when to set and change a user ID.

 AppboyPlugin.changeUser("YOUR_USER_ID");

Logging Custom Events

See the Android integration instructions for in depth discussion of event tracking best practices and interfaces.

var properties = {};
properties["KeyOne"] = "Val1";
AppboyPlugin.logCustomEvent("cordovaCustomEventWithProperties", properties);

Setting Custom Attributes

See the Android integration instructions for in depth discussion of attribute tracking best practices and interfaces.

AppboyPlugin.setFirstName("firstName");

Logging Purchases

See the Android integration instructions for in depth discussion of revenue tracking best practices and interfaces.

var properties = {};
properties["KeyOne"] = "ValueOne";
AppboyPlugin.logPurchase("testPurchaseWithNullCurrency", 10, null, 5, properties);

News Feed

See the Android integration instructions for information on how to integrate the news feed into your Cordova app. Alternatively, our Cordova plugin provides a method, launchNewsFeed, that will launch a modal news feed without further integration.

The Appboy Cordova SDK has several methods to get the number of read/unread News Feed cards for different categories. See our sample project implementation for an example.

You can look at the sample Android application and sample Cordova application implementation samples.

Customer Feedback

See the Android integration instructions for information on how to integrate the feedback form into your Cordova app. Alternatively, the Cordova plugin provides a launchFeedback method that will launch a modal feedback element over your application.

You can look at the sample Android application and sample Cordova application implementation samples.