This guide analyzes the entire plugin, its native bindings, and the sample dengage-cordova-example project so even someone new to Dengage can integrate it step by step.
1. Repository Anatomy
| Path | Purpose |
|---|---|
plugin.xml | Cordova wiring: maps www/Dengage.js to DengageCR, declares Android/iOS source files, and adds Firebase/Dengage dependencies plus the Swift helper plugin. |
www/Dengage.js | JavaScript bridge. Every method calls cordova.exec(success, error, 'DengageCR', action, args). The file exposes identity, push, commerce, inbox, in-app, navigation, and configuration helpers. |
src/android/ | Native bridge for Android: DengageCR.java (Cordova plugin), DengageCRCoordinator.java (SDK init + lifecycle watchers), InAppInlineHostView.java, StoriesListHostView.java. |
src/ios/ | Native bridge for iOS: DengageCR.swift (Js-to-native proxy), DengageCRCoordinator.swift, and overlay views (DengageInlineOverlayView, DengageAppStoryOverlayView). |
www/ (in the plugin) | Exposed JS. |
dengage-cordova-example/ | Opinionated working Cordova app showing how to initialize the SDK (www/js/dengage-init.js), hook navigation, and exercise every feature. |
USAGE_GUIDE.md | Quick-start snippets that you can copy into your app. |
2. Getting Ready
- Install Cordova CLI:
npm install -g cordova - Have a Firebase project for Android (you need
google-services.json). - Have Apple Push Notification credentials plus an APNs key/certificate if you want iOS push.
- (Optional) If you target Huawei devices, get
agconnect-services.jsonand the HMS SDK keys.
3. Plugin Install & Verification
cordova plugin add cordova-plugin-dengageor, to iterate on the SDK locally:
cordova plugin add /absolute/path/to/dengage-cordova-sdkVerify the plugin is registered:
cordova plugin listIt should report cordova-plugin-dengage.
4. Default Dengage API Endpoints (customize if Dengage Support gave you region-specific URLs)
| Meta-data / Info.plist key | Default value | Description |
|---|---|---|
den_event_api_url | https://event.dengage.com | Event ingestion endpoint. |
den_push_api_url | https://push.dengage.com | Push notification endpoint. |
den_device_id_api_url | https://device.dengage.com | Device identity endpoint used for contact tracking. |
den_in_app_api_url | https://inapp.dengage.com (add manually if required) | In-app message rendering endpoint. |
den_geofence_api_url | https://geofence.dengage.com (add with geofence module) | Geofence triggers. |
fetch_real_time_in_app_api_url | https://realtime.dengage.com (if provided) | Real-time in-app polling. |
If your team already has datacenter URLs from the Dengage dashboard, merge them into config.xml (Android <config-file> pointing at AndroidManifest.xml and iOS <edit-config> to the *-Info.plist).
4.1 Platform-Specific Endpoint Keys
- Android wires the endpoint URLs via
<meta-data>entries namedden_event_api_url,den_push_api_url,den_device_id_api_url, etc. These values get merged into the generatedAndroidManifest.xmland are read by the native Dengage SDK when it initializes. - iOS uses property-list keys such as
DengageEventApiUrl,DengagePushApiUrl,DengageDeviceIdApiUrl,DengageInAppApiUrl,DengageGeofenceApiUrl, andfetchRealTimeINAPPURL. Add these with<edit-config>entries so Cordova keeps them synced withInfo.plist. - Example configuration:
<platform name="android">
<config-file parent="./application" target="AndroidManifest.xml">
<meta-data android:name="den_event_api_url" android:value="https://event.dengage.com"/>
<meta-data android:name="den_push_api_url" android:value="https://push.dengage.com"/>
<meta-data android:name="den_device_id_api_url" android:value="https://device.dengage.com"/>
<meta-data android:name="den_in_app_api_url" android:value="https://inapp.dengage.com"/>
<meta-data android:name="den_geofence_api_url" android:value="https://geofence.dengage.com"/>
<meta-data android:name="fetch_real_time_in_app_api_url" android:value="https://realtime.dengage.com"/>
</config-file>
</platform>
<platform name="ios">
<edit-config file="*-Info.plist" mode="merge" target="DengageEventApiUrl">
<string>https://event.dengage.com</string>
</edit-config>
<edit-config file="*-Info.plist" mode="merge" target="DengagePushApiUrl">
<string>https://push.dengage.com</string>
</edit-config>
<edit-config file="*-Info.plist" mode="merge" target="DengageDeviceIdApiUrl">
<string>https://device.dengage.com</string>
</edit-config>
<edit-config file="*-Info.plist" mode="merge" target="DengageInAppApiUrl">
<string>https://inapp.dengage.com</string>
</edit-config>
<edit-config file="*-Info.plist" mode="merge" target="DengageGeofenceApiUrl">
<string>https://geofence.dengage.com</string>
</edit-config>
<edit-config file="*-Info.plist" mode="merge" target="fetchRealTimeINAPPURL">
<string>https://realtime.dengage.com</string>
</edit-config>
</platform>Cordova merges these entries during cordova prepare, so you don’t edit the generated manifest/Info.plist manually.
5. Android Integration (Native + Cordova)
-
Manifest / Gradle prep
- Drop
google-services.jsonintoplatforms/android/app/. - Apply the Firebase Gradle plugin:
// project-level build.gradle dependencies { classpath 'com.google.gms:google-services:4.3.15' } // app-level build.gradle apply plugin: 'com.google.gms.google-services' - Add the Firebase service declaration inside
<application>:<service android:name="com.dengage.sdk.push.FcmMessagingService" android:exported="false"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service> - Add any Dengage meta-data (copy values from the table above) via
config.xmlso Cordova injects them intoAndroidManifest.xmlduring build.
- Drop
-
Native Initialization (MainActivity / Application)
- Import and call
DengageCRCoordinator.getInstance().setupDengage(...)beforeloadUrl(launchUrl)inMainActivity:DeviceConfigurationPreference deviceConfig = DeviceConfigurationPreference.Google; DengageCRCoordinator.getInstance().setupDengage( "YOUR_FIREBASE_KEY", null, // HMS key if you also build for Huawei getApplicationContext(), null, // optional IDengageHmsManager deviceConfig, false, // disable open web urls when push clicked true, // log enabled (turn off in production) false, // enable geofence false // development status ); DengageCRCoordinatorensures:Firebase keyis not null (throws if it is).DengageLifecycleTrackeris registered viaApplication.registerActivityLifecycleCallbacks.Dengage.INSTANCE.init(…)is invoked (falling back to Kotlin-style defaults).- Logging and
developmentStatusare applied. - If
enableGeoFenceis true, it tries to loadcom.dengage.geofence.DengageGeofence.startGeofence()via reflection (includesdk-geofencein Gradle for this to succeed).
- Import and call
-
In-App / Stories Host Views
DengageCR.javakeeps singletons (inlineHostView,storyHostView). When JS callsshowInAppInlineorshowAppStory, it:- Reads
propertyId,screenName, optionalcustomParams, andboundsfrom the JSON payload. - Runs on the UI thread, inflates
InAppInlineHostVieworStoriesListHostView, inserts it into the root view (android.R.id.content) with elevation to stay on top, and callsDengage.INSTANCE.showInlineInApporshowStoriesList. - The layout bounds are computed via
buildLayoutParams, which respects the containerleft,top,width,height(converted from dips). - Each host view sets
hasRenderedso the same container is not re-used untilhideInAppInline/hideAppStoryremoves it from the view hierarchy.
- Reads
-
Geofence and Permissions
- Set
enableGeoFencetotrueinsetupDengagewhen you includesdk-geofence. The coordinator tries to load the class; if the JAR is missing, you will see a warning in Logcat. - From JavaScript you can call
DengageCR.requestLocationPermissions(success, error)to prompt Android 13+ runtime notification permission (and location if required).
- Set
-
Huawei (optional)
- Add
sdk-hmsand set upagconnect-services.json+com.huawei.agconnectplugin as described inUSAGE_GUIDE.md. - Pass
DengageHmsManager(implementsIDengageHmsManager) and your Huawei integration key intosetupDengage. The coordinator forwards it toDengage.INSTANCE.init.
- Add
6. iOS Integration (Native Steps)
-
CocoaPods
- Navigate to
platforms/iosand runpod installso CocoaPods fetches theDengageSDK specified inplugin.xml(pod 'Dengage', '~> 5.85').
- Navigate to
-
Capabilities &Entitlements
- In Xcode, enable Push Notifications and under Background Modes check Remote notifications.
-
AppDelegate Wiring
- Import and call
DengageCRCoordinator.staticInstance.setupDengage(...)fromapplication(_:didFinishLaunchingWithOptions:):DengageCRCoordinator.staticInstance.setupDengage( key: "YOUR_IOS_INTEGRATION_KEY", appGroupsKey: "group.your.app", // optional launchOptions: launchOptions as NSDictionary?, application: application, askNotificationPermission: true, // prompt user automatically enableGeoFence: false, // enable if you include the geofence pod disableOpenURL: false, badgeCountReset: true, logVisible: true ) - Forward APNs callbacks:
didRegisterForRemoteNotificationsWithDeviceToken: callDengageCRCoordinator.staticInstance.registerForPushToken(deviceToken:).userNotificationCenter(_:didReceive:withCompletionHandler:)andapplication(_:didReceiveRemoteNotification:): forward to the coordinator to let Dengage handle deep links and analytics.
- Import and call
-
Swift / View Components
DengageCR.swiftmirrors the JS API and hands off toDengageCRCoordinator.swift, which calls the Swift Dengage SDK for in-app, inbox, real-time, etc.- Inline overlays are rendered via
DengageInlineOverlayViewand stories useDengageAppStoryOverlayView. The plugin automatically adds them when JS requests inline/story content; you only need to passpropertyId,screenName, and bounds from the web UI.
-
Swift Version Support
- The plugin depends on
cordova-plugin-add-swift-supportand setsUseSwiftLanguageVersionto5. No manual bridging headers are necessary.
- The plugin depends on
7. JavaScript Runtime & API Catalog (www/Dengage.js)
www/Dengage.js)- Wait for
devicereadybefore calling Dengage APIs (seedengage-cordova-example/www/js/index.js). Cordova’s bridge relies on native modules being initialized first. - Always provide both
successanderrorcallbacks; the native calls are asynchronous and nursing the callbacks lets you display logs, update UI, or surface problems.
7.1 Identity and Device Helpers
setContactKey(key)/getContactKey()— tie the device to your user identity; call early, especially if you already have a login/token. If you need cross-platform IDs,setDeviceId(deviceId)lets you force a specific identifier whilegetDeviceId()lets you read what Dengage has generated.setPartnerDeviceId(adid)— keep Dengage in sync with any partner tracking ID (for example, an external attribution SDK’s advertising ID).- Locale enrichers:
setLanguage,setCountry,setCity,setState,setDevelopmentStatusset contextual metadata that Dengage templates and targeting rules can reference. getSdkVersion()/getIntegrationKey()/getSdkParameters()allow debugging: print the values to confirm the SDK version, integration key, or the event mapping table returned from the backend.
7.2 Push, Permissions, and Payloads
registerNotification()should be invoked once at startup. It registers the broadcast receiver on Android and re-subscribes iOS devices after every launch.promptForPushNotifications()andpromptForPushNotificationsWithCallback()(iOS only) trigger the APNs permission dialog and let you track the user’s decision.setPermission(true/false)/getPermission()allow manual toggles (for example, when the user controls their own notification switch inside your app).getMobilePushToken()/setMobilePushToken(token)let you sync the Firebase token manually (useful if you have your own push infrastructure or migration scenario).getLastPushPayload()surfaces the payload of the last received notification for custom handling.resetAppBadge()clears the Android badge when the user opens the app manually.getUserPermission()reads the current permissions state for display in settings screens.
7.3 Commerce and Event Logging
pageView({ screenName })/viewCart(...)/addToCart(data)/removeFromCart(data)/beginCheckout(...)/placeOrder(data)/cancelOrder(data)/setCart(cart)/getCart()/setCartItemCount()/setCartAmount()/setCategoryPath()— each writes a pre-defined event table to Dengage so you can trigger campaigns based on real e-commerce activity. Use the helper screens underwww/js/screens/cart.jsas a blueprint for the data shape.search(data)captures search terms for personalization.sendDeviceEvent(table, data)/sendCustomEvent(table, key, params)let you send arbitrary event names and payloads, giving you flexibility beyond the prebuilt commerce tables.setTags(tagArray)lets you annotate the device with custom metadata (e.g., loyalty tier). The SDK will merge the tags before every sync automatically.
7.4 In-App Experiences (navigation, inline, stories, realtime)
setNavigation(),setNavigationWithName(screenName),setNavigationWithNameAndData(screenName, data)inform Dengage about the current screen so campaigns can fire for that view. Always call this before showing in-app content.showRealTimeInApp(screenName, params)asks the Dengage server for the next eligible in-app for the current screen. Combine it withsetCity,setState,setCartItemCount, andsetCartAmountto send richer context; the RTS example screen uses these calls.- Inline overlays: build a payload
{ propertyId, screenName, customParams?, bounds }and callshowInAppInline(payload)to render a native inline widget at the computed DOM bounds.hideInAppInline()removes it when you are done. - App stories:
showAppStory(payload)andhideAppStory()work similarly but use the story host view for side-scrolling creative. setInAppDeviceInfo(key, value)pushes small key/value pairs to whatever in-app template is currently shown. The inline HTML can read these values via thednInAppDeviceInfoobject, allowing templates to personalize content without reloading the app.clearInAppDeviceInfo()andgetInAppDeviceInfo()help you manage/reset these values when you leave the screen or reveal a new campaign.
7.5 Inbox, Deeplinks, and Helpers
getInboxMessages(offset, limit)/deleteInboxMessage(id)/deleteAllInboxMessages()/setInboxMessageAsClicked(id)/setAllInboxMessageAsClicked()provide a full inbox management surface. The inbox screen inwww/js/screens/inbox-messages.jsdemonstrates pagination, removable entries, and clicked state rendering.setInAppLinkConfiguration(url)overrides the defaultinAppLinkConfigurationprovided byDengageCRCoordinator. Use it when your app uses universal links or custom URL handling.registerInAppLinkReceiver()listens for native callbacks triggered by in-app or push deep links and supplies them to JavaScript.getSdkParameters()returns theDengageSDKParametermapping so you can see which tables and keys are available server-side when building analytics features.getDeviceId()/getIntegrationKey()provide the identifiers you can send to your backend or CRM for cross-referencing.
7.6 Location & Geofence
- Include the optional geofence dependency (
sdk-geofence) and passenableGeoFence: truetosetupDengage. The coordinator uses reflection to callDengageGeofence.startGeofence(). requestLocationPermissions()pops up the run-time permission dialog (needed on Android 13+ when background location is required by geofence campaigns).- After permissions are granted, Dengage can trigger geofence campaigns purely from the native SDK; no extra JavaScript call is needed beyond enabling the module.
7.7 Custom Payload Handling
- Use
registerNotificationcallback to listen forPUSH_RECEIVEandPUSH_OPENevents on the JavaScript side and inspect the payload for custom data, links, or analytics. getLastPushPayload()is helpful when you want to show an in-app banner containing the last notification that arrived during the current session.
7.8 Function-by-Function Reference
Each of the functions exposed by www/Dengage.js proxies to cordova.exec. Call patterns usually look like DengageCR.method(args, success, error). The examples below align with the screens inside dengage-cordova-example/www/js/screens/ so you can cross-reference them inside the sample app; copy the snippet that matches your use case and adjust the payload for your own data.
setContactKey(contactKey, success, error)
Bind the device to your customer ID before sending events. Include a success and error callback to confirm the call completed:
DengageCR.setContactKey('user-123', () => console.log('contact key saved'), console.error);setLogStatus(logStatus, success, error)
Enable or disable verbose SDK logs on the current device.
DengageCR.setLogStatus(true, () => console.log('logging on'), console.error);registerNotification(success, error)
Registers push notification listeners (Android receiver + iOS re-subscribe). Use the success callback to receive every PUSH_RECEIVE/PUSH_OPEN payload.
DengageCR.registerNotification(payload => console.log('payload', JSON.stringify(payload, null, 2)), console.error);setPermission(permission, success, error)
Manually toggle whether the SDK should treat the device as opted-in.
DengageCR.setPermission(true, () => console.log('permission enabled'), console.error);setMobilePushToken(token, success, error)
Push a Firebase token computed outside the SDK (migration or custom push service).
DengageCR.setMobilePushToken('firebase-token-xyz', () => console.log('token set'), console.error);getMobilePushToken(success, error)
Retrieve the token Dengage currently uses for push.
DengageCR.getMobilePushToken(token => console.log('token =', token), console.error);getContactKey(success, error)
Read back the contact key already stored for this device.
DengageCR.getContactKey(key => console.log('current user', key), console.error);getPermission(success, error)
Check whether Dengage thinks notifications are enabled.
DengageCR.getPermission(permission => console.log('permission:', permission), console.error);getSubscription(success, error)
Retrieve raw subscription metadata (integration key, tokens, device IDs, etc.).
DengageCR.getSubscription(sub => console.log('subscription', sub), console.error);pageView(data, success, error)
Log a page view event to Dengage with arbitrary metadata (screen name, category).
DengageCR.pageView({ screenName: 'home' }, console.log, console.error);addToCart(data, success, error)
Send a cart-item insertion event. Provide at least productId, quantity, and price.
DengageCR.addToCart({ productId: 'sku-1', quantity: 1, price: 450 }, console.log, console.error);removeFromCart(data, success, error)
Remove an item or decrement quantity in Dengage’s cart tracking.
DengageCR.removeFromCart({ productId: 'sku-1', quantity: 1 }, console.log, console.error);viewCart(data, success, error)
Trigger a cart view event so Dengage knows the current cart size/total.
DengageCR.viewCart({ items: 2, value: 900 }, console.log, console.error);beginCheckout(data, success, error)
Mark the start of a checkout flow; include currency, channel, or other campaign data.
DengageCR.beginCheckout({ orderId: 'ord-1', value: 900 }, console.log, console.error);placeOrder(data, success, error)
Send complete order data after a successful payment.
DengageCR.placeOrder({ orderId: 'ord-1', subtotal: 900, discount: 100 }, console.log, console.error);cancelOrder(data, success, error)
Report canceled transactions to keep analytics accurate.
DengageCR.cancelOrder({ orderId: 'ord-1', reason: 'user-request' }, console.log, console.error);addToWishList(data, success, error)
Track wishlist adds for personalization.
DengageCR.addToWishList({ productId: 'sku-1', name: 'Sneaker' }, console.log, console.error);removeFromWishList(data, success, error)
Remove an item from the wishlist tracking table.
DengageCR.removeFromWishList({ productId: 'sku-1' }, console.log, console.error);search(data, success, error)
Log search terms to trigger search-related automations.
DengageCR.search({ keyword: 'leather boots' }, console.log, console.error);setTags(data, success, error)
Attach tagged metadata (arrays of { tagName, tagValue }) to the device.
DengageCR.setTags([{ tagName: 'tier', tagValue: 'gold' }], console.log, console.error);sendDeviceEvent(tableName, data, success, error)
Write a custom event to your Dengage-defined table.
DengageCR.sendDeviceEvent('purchase_history', { sku: 'sku-1' }, console.log, console.error);getInboxMessages(offset, limit, success, error)
Paginate stored inbox messages that Dengage saves when “Save to Inbox” is enabled.
DengageCR.getInboxMessages(0, 20, messages => console.log(messages), console.error);deleteInboxMessage(id, success, error)
Remove a single inbox entry.
DengageCR.deleteInboxMessage('msg-123', () => console.log('deleted'), console.error);setInboxMessageAsClicked(id, success, error)
Mark a message as read/clicked.
DengageCR.setInboxMessageAsClicked('msg-123', () => console.log('clicked'), console.error);promptForPushNotifications(success, error)
Show the native iOS permission dialog (iOS-only).
DengageCR.promptForPushNotifications(() => console.log('prompt shown'), console.error);promptForPushNotificationsWithCallback(success, error)
Same as above but keeps the callback to inform the app when the user responds.
DengageCR.promptForPushNotificationsWithCallback(result => console.log(result), console.error);setNavigation(success, error)
Notify the SDK that navigation was handled (default uses current screen).
DengageCR.setNavigation(() => console.log('navigation recorded'), console.error);setNavigationWithName(screenName, success, error)
Explicitly provide a screen identifier so Dengage can tie campaigns to it.
DengageCR.setNavigationWithName('product-detail', () => console.log('screen set'), console.error);setNavigationWithNameAndData(screenName, screenData, success, error)
Pass extra context (e.g., product ID) right alongside the screen name.
DengageCR.setNavigationWithNameAndData('product-detail', { productId: 'sku-1' }, () => console.log('nav+data'), console.error);setCategoryPath(path, success, error)
Tell Dengage which category the user is browsing.
DengageCR.setCategoryPath('men/shoes', () => console.log('category set'), console.error);setCartItemCount(itemCount, success, error)
Update the cart item counter to help real-time campaigns target busy carts.
DengageCR.setCartItemCount(3, () => console.log('cart count 3'), console.error);setCartAmount(amount, success, error)
Report total cart value for threshold-based campaigns.
DengageCR.setCartAmount(1250, () => console.log('cart amount tracked'), console.error);setState(state, success, error)
Flag the user’s current state for location-based personalization.
DengageCR.setState('Texas', () => console.log('state set'), console.error);setCity(city, success, error)
Flag city-level context.
DengageCR.setCity('Austin', () => console.log('city set'), console.error);showRealTimeInApp(screenName, data, success, error)
Ask Dengage for an immediate real-time inline. data typically mirrors setCity, setState, setCategoryPath, etc.
DengageCR.showRealTimeInApp('homepage', { categoryPath: 'men/shoes' }, console.log, console.error);showInAppInline(payload, success, error)
Render an inline overlay inside a native container. Provide propertyId, screenName, optional customParams, and bounds.
DengageCR.showInAppInline({
propertyId: '1',
screenName: 'home-inline',
bounds: { left: 10, top: 100, width: 300, height: 160 }
}, console.log, console.error);hideInAppInline(success, error)
Remove the inline overlay so you can show a different campaign later.
DengageCR.hideInAppInline(() => console.log('inline hidden'), console.error);showAppStory(payload, success, error)
Play an app story overlay; similar payload expectations as inline.
DengageCR.showAppStory({
propertyId: '1',
screenName: 'story-screen',
customParams: { theme: 'seasonal' }
}, console.log, console.error);hideAppStory(success, error)
Hide the currently visible story.
DengageCR.hideAppStory(() => console.log('story hidden'), console.error);setPartnerDeviceId(adid, success, error)
Keep Dengage aware of third-party device identifiers.
DengageCR.setPartnerDeviceId('partner-abc', () => console.log('partner id saved'), console.error);getLastPushPayload(success, error)
Read the raw payload of the last notification the SDK received.
DengageCR.getLastPushPayload(payload => console.log(payload), console.error);setInAppLinkConfiguration(deeplink, success, error)
Override the default deep-link host used when in-app/inbox messages open URLs.
DengageCR.setInAppLinkConfiguration('myapp://handle', console.log, console.error);registerInAppLinkReceiver(success, error)
Listen for deep-link callbacks from the native side; the success callback receives the URL string.
DengageCR.registerInAppLinkReceiver(url => console.log('deep link', url), console.error);sendCustomEvent(eventTable, key, parameters, success, error)
Write to a Dengage custom big data table with structured payload.
DengageCR.sendCustomEvent('custom_table', 'click', { label: 'cta' }, console.log, console.error);setCart(cart, success, error)
Upload a full cart with items array and summary.
DengageCR.setCart({ items: [], summary: { subtotal: 0 } }, console.log, console.error);getCart(success, error)
Retrieve the cart that Dengage currently tracks.
DengageCR.getCart(cart => console.log(cart), console.error);getSdkParameters(success, error)
Fetch event tables / key mappings that Dengage returns for diagnostics.
DengageCR.getSdkParameters(params => console.log(params), console.error);setInAppDeviceInfo(key, value, success, error)
Share small key/value metadata for templates.
DengageCR.setInAppDeviceInfo('loyaltyLevel', 'gold', console.log, console.error);clearInAppDeviceInfo(success, error)
Remove every in-app device info entry.
DengageCR.clearInAppDeviceInfo(() => console.log('cleared'), console.error);getInAppDeviceInfo(success, error)
Inspect the key/value pairs currently stored on the client.
DengageCR.getInAppDeviceInfo(info => console.log(info), console.error);deleteAllInboxMessages(success, error)
Wipe every stored inbox message (for debugging or logout scenarios).
DengageCR.deleteAllInboxMessages(() => console.log('inbox cleared'), console.error);setAllInboxMessageAsClicked(success, error)
Mark every stored message as clicked.
DengageCR.setAllInboxMessageAsClicked(() => console.log('all marked read'), console.error);getDeviceId(success, error)
Read the device ID Dengage uses internally.
DengageCR.getDeviceId(id => console.log('device id', id), console.error);setDeviceId(deviceId, success, error)
Force a specific device ID (use with caution).
DengageCR.setDeviceId('device-123', () => console.log('device id forced'), console.error);setLanguage(language, success, error)
Set the device’s language context for message targeting.
DengageCR.setLanguage('en-US', () => console.log('language set'), console.error);setDevelopmentStatus(isDebug, success, error)
Mark the SDK as running in development mode so it behaves differently (logs, geofence). Pass true / false.
DengageCR.setDevelopmentStatus(true, () => console.log('dev mode on'), console.error);requestLocationPermissions(success, error)
Android 13+ permission prompt helper for geofence campaigns.
DengageCR.requestLocationPermissions(() => console.log('location prompt'), console.error);getIntegrationKey(success, error)
Retrieve the integration key for debugging or backend sync.
DengageCR.getIntegrationKey(key => console.log('integration key', key), console.error);getUserPermission(success, error)
Read the latest user permission state (similar to getPermission but always returns an explicit boolean).
DengageCR.getUserPermission(permission => console.log('user permission', permission), console.error);resetAppBadge(success, error)
Clear Android badges when you manually open the app.
DengageCR.resetAppBadge(() => console.log('badge reset'), console.error);getSdkVersion(success, error)
Check the version of the native Dengage SDK that is running.
DengageCR.getSdkVersion(version => console.log('SDK version', version), console.error);7.9 Inline Overlays & App Story Usage
Inline overlays and app stories are native containers that require a payload before being shown. The sample screens (www/js/screens/in-app-inline.js and www/js/screens/app-story.js) demonstrate the full workflow.
-
Inline overlay steps
- Capture the DOM container bounds with
element.getBoundingClientRect()and convert to{ left, top, width, height }. - Build the inline payload:
{ propertyId, screenName, customParams?, bounds }. - Call
DengageCR.showInAppInline(payload, success, error); the native host view uses the bounds (converted to density-independent pixels on Android) so the overlay matches the target region. - When you no longer need the inline experience, run
DengageCR.hideInAppInline(() => console.log('inline hidden'), console.error)to remove it.
- Capture the DOM container bounds with
-
App Story steps
- Prepare
{ propertyId, screenName, customParams? }without bounds because the story floats above the UI. - Call
DengageCR.showAppStory(payload, success, error)to present the story overlay. - Dismiss with
DengageCR.hideAppStory(() => console.log('story hidden'), console.error)when the story should exit.
- Prepare
The inline and story helpers both log successes/errors to help you debug placement; adjust the payload values to match the campaigns you created in your Dengage dashboard. Use the customParams field for personalization data, and remember to call setNavigationWithName before invoking an inline or story so the SDK knows which screen is active.
8. In-App Stories & Inline Overlays
showInAppInline/showAppStoryinject native overlays viaInAppInlineHostViewandStoriesListHostView.- The payload MUST include
propertyIdandscreenName;customParamsandboundsare optional but recommended. - The example screens show how to gather
boundsusingelement.getBoundingClientRect()and pass stringified JSON to the plugin. hideInAppInline/hideAppStoryremoves the host view so you can refresh the experience.
9. App Inbox
If messages are sent with “Save to Inbox” in the Dengage dashboard, they are captured locally and accessible via:
getInboxMessages(offset, limit, ...)deleteInboxMessage(id, ...)deleteAllInboxMessages(...)setInboxMessageAsClicked(id, ...)setAllInboxMessageAsClicked(...)
The example screens/inbox-messages.js shows how to populate a list, delete entries, and mark items as read.
10. Push Messaging & Permissions
- Android registers the
FcmMessagingService, iOS uses the AppDelegate helper. - Always call
registerNotificationon startup (it re-subscribes the device on iOS). - Use
promptForPushNotifications/promptForPushNotificationsWithCallbackto request user permission on iOS;setPermission/getPermissionare there if you manage permission toggles yourself. getMobilePushToken/setMobilePushTokenlet you sync tokens with Dengage manually.- For Android 13+ you can
requestLocationPermissions(the plugin usesDengage.INSTANCE.requestLocationPermission). resetAppBadgeclears the badge count on Android. iOS badge reset is handled viabadgeCountResetparameter duringsetupDengage.
11. Geofence & Location Triggers
- Include
sdk-geofence(via Gradle or CocoaPods) and set theenableGeoFenceflag to true while initializing. - The coordinator automatically tries to load
com.dengage.geofence.DengageGeofence.startGeofence(). - Use
DengageCR.requestLocationPermissionsto satisfy the runtime permission request if your app triggers location-based campaigns.
12. Deeplinks & URLs
- By default the Android coordinator calls
Dengage.INSTANCE.inAppLinkConfiguration("www.chaitanyamunje.com"). Override it from JS with:DengageCR.setInAppLinkConfiguration('https://your.app.link'); - Call
registerInAppLinkReceiver()to let the plugin listen for native deep link callbacks. When a push/in-app message opens a URL, the payload is forwarded to JS so you can navigate inside the WebView. setNavigationWithNameAndData(screenName, data, ...)is helpful when your nav system needs extra context (the example uses it to tell Dengage which product the user is viewing).
13. Example App Breakdown (dengage-cordova-example)
dengage-cordova-example)| Feature | Files & notes |
|---|---|
| App bootstrap | www/js/index.js → waits for deviceready, initializes navigation and calls initializeDengage() (see www/js/dengage-init.js). |
| Contact management | www/js/screens/contact-key.js: reads/saves contact key, toggles notification permission. |
| Device info | www/js/screens/device-info.js: attempts getSubscription, falls back to getContactKey, getMobilePushToken, getDeviceId, getIntegrationKey, getSdkVersion so you can inspect what the SDK thinks about the device. |
| Event history | www/js/screens/event-history.js: reads getSdkParameters() (event mappings) and lets you send any custom event table via sendDeviceEvent. |
| Cart | www/js/screens/cart.js: demonstrates getCart, editing cart items, and submitting setCart(...) with summary data. |
| Geofence | www/js/screens/geofence.js: calls requestLocationPermissions. |
| In-app messaging | www/js/screens/in-app-message.js: manipulates setInAppDeviceInfo, setNavigationWithName, and setNavigation; also clears device info via clearInAppDeviceInfo. |
| Real-time in-app | www/js/screens/rt-in-app-message.js: sets cart state (setCartItemCount/Amount), setCategoryPath, setCity, setState, then calls showRealTimeInApp. |
| Inline messages | www/js/screens/in-app-inline.js: builds a payload with propertyId, screenName, customParams, and bounds, then calls showInAppInline / hideInAppInline. Boundaries are derived from the DOM container’s getBoundingClientRect(). |
| App stories | www/js/screens/app-story.js: similar to inline but calls showAppStory / hideAppStory. Adjusts container color to illustrate layout changes. |
| Inbox | www/js/screens/inbox-messages.js: fetches inbox messages, shows metadata (isClicked, receiveDate), deletes messages, and marks them as clicked. |
| Navigation | www/js/navigation.js: simple screen swapping logic that keeps the UI in sync with the SDK. |
Running the sample project
- Install dependencies inside the example:
cd ../dengage-cordova-example && npm install. - Add platforms if needed:
cordova platform add android/cordova platform add ios. - Build & run:
cordova run androidorcordova run ios. The example already includesconfig.xml,platforms/, and plugin wiring so you can even open it directly in Android Studio/Xcode.
14. Testing & Troubleshooting
- Enable verbose logging on dev devices:
DengageCR.setLogStatus(true, console.log, console.error)from JS. Disable before release. - If push is not arriving:
- Android: confirm
google-services.jsonis inplatforms/android/app/and the Firebase Server Key is configured in the Dengage dashboard. - iOS: check APNs certificates, that push capabilities are enabled, and that
didRegisterForRemoteNotificationsWithDeviceTokenforwards to the coordinator.
- Android: confirm
- Ensure contact keys are set before relying on event personalization. Use the example
screens/contact-key.jsto verify. - Use
DengageCR.getSdkParameters(seescreens/event-history.js) to inspect the data returned from Dengage and match it against your dashboard’s event mappings. - If in-app messages fail to appear, send the screen name via
setNavigationWithNameand verify that the same screen name is listed in your Dengage campaign targeting rules. - Track inline/story behavior by inspecting the DOM container’s bounds (the example uses
getBoundingClientRect). If the overlay appears off-screen, adjust theboundsbefore callingshowInAppInline/showAppStory. - When troubleshooting inbox,
getInboxMessagesreturns message metadata (receiveDate,title,message,isClicked). UsedeleteInboxMessage/setInboxMessageAsClickedto keep the list manageable.
15. Resources & Links
- Sample app repository: https://github.com/dengage-tech/dengage-cordova-sdk-sample