Skip to content

Cordova integration

This article covers initial SDK setup steps for apps running on Cordova.

Setting a custom API endpoint

A custom API endpoint can be configured via the config.xml. For example, to use the EU endpoint, see the following:

Android

1
2
3
4
<platform name="android">
    ...
    <preference name="com.braze.android_api_endpoint" value="sdk.fra-01.braze.eu" />
</platform>

iOS

1
2
3
4
<platform name="ios">
    ...
    <preference name="com.braze.ios_api_endpoint" value="sdk.fra-01.braze.eu" />
</platform>

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 or iOS integration instructions.

In-app messaging

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

Analytics

Setting user IDs

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

1
BrazePlugin.changeUser("YOUR_USER_ID");

Logging custom events

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

1
2
3
var properties = {};
properties["KeyOne"] = "Val1";
BrazePlugin.logCustomEvent("cordovaCustomEventWithProperties", properties);

Setting custom attributes

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

1
BrazePlugin.setFirstName("firstName");

Logging purchases

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

1
2
3
var properties = {};
properties["KeyOne"] = "ValueOne";
BrazePlugin.logPurchase("product_id_with_null_currency", 10, null, 5, properties);

Log purchases at the order level

If you would like to log purchases at the order level instead of the product level, you can use order name or order category as the product_id. Refer to our purchase object specification to learn more.

News Feed

See the Android and iOS 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 Braze Cordova SDK has several methods to get the number of read or unread News Feed cards for different categories. Check out a sample project implementation for an example.

WAS THIS PAGE HELPFUL?
New Stuff!