Add a placement
The Rokt Cordova SDK can be used by Rokt partners to display overlay placements, or by Rokt advertisers to record conversions for campaigns.
Before you begin
Ensure that the Rokt Cordova SDK has been integrated into your application.
Execute the Rokt Cordova SDK
execute
the Rokt Cordova SDK to show your placement. successCallback
returns a message parameter that allows you to track SDK events.
RoktSDK.execute(
"RoktExperience",
{
"email" : "j.smith@example.com",
"firstname": "Ginger",
"lastname": "Smith",
"mobile": "(555)867-5309",
"postcode": "90210",
"country": "US"
},
function(msg) {
console.log(msg);
// msg can be any of these
// 1. onLoad - your placement loads
// 2. onUnload - your placement unloads
// 3. onShouldHideLoadingIndicator - hook to show a loading indicator
// 4. onShouldShowLoadingIndicator - hook to hide a loading indicator
},
function(err) {
console.log(err);
}
);
Callbacks
The Rokt Cordova SDK supports callbacks via Cordova Plugin Results. You can listen to the callback values in a function passed to the execute
function:
RoktSDK.execute(
"RoktExperience",
{
"email" : "j.smith@example.com",
"firstname": "Ginger",
"lastname": "Smith",
"mobile": "(555)867-5309",
"postcode": "90210",
"country": "US"
},
function(callbackValue) {
switch (callbackValue) {
case "onLoad":
// onLoad
case "onUnload":
// onUnload
case "onShouldShowLoadingIndicator":
// onShouldShowLoadingIndicator
case "onShouldHideLoadingIndicator":
// onShouldHideLoadingIndicator
default:
// default
}
},
function(err) {
console.log(err);
}
);
Callback types
onLoad
The onLoad
callback will be called when the placement becomes loaded and interactive.
onShouldShowLoadingIndicator
The onShouldShowLoadingIndicator
will be called upon a successful execute call, just before the SDK triggers a call to the Rokt backend. It can be used to display progress views of loading indicators while waiting for the placement to load.
onShouldHideLoadingIndicator
The onShouldHideLoadingIndicator
callback will be called when the SDK obtains a success or failure response from the Rokt backend. It can be used to cancel progress views or loading indicators.
onUnload
The onUnload
callback will be called when the SDK closes the placement. It will also be triggered if the execute call fails.
Using App Configurations
Applications can now send configuration settings from their own application environment. This allows Rokt SDK to use application custom configurations instead of relying solely on system defaults.
// if application supports only Light Mode.
const roktConfig = new RoktSDK.RoktConfigBuilder()
.withColorMode(RoktSDK.COLOR_MODE.LIGHT)
.build();
RoktSdk.executeWithConfig(
// other params,
roktConfig,
)
ColorMode object
Value | Description |
---|---|
LIGHT | Application is in Light Mode |
DARK | Application is in Dark Mode |
SYSTEM | Application defaults to System Color Mode |