Integrate the Connect SDK into a Cordova app

You can integrate the Connect SDK into your Cordova app and get it running on iOS and Android through one JavaScript API.

Language: JavaScript (vanilla · framework-bundled), with TypeScript definitions

Availability: Pro, Premium, and Ultimate

Scope: This guide covers installing the plugin and getting the SDK running for development and testing. For push notification setup, see iOS and Android.


Requirements

  • Acoustic Connect subscription. Register your app in Connect and get an app key and collector URL. See Generate Connect credentials for integration.
  • Development environment. Node.js 20 or later, Cordova CLI 12.0.0 or later (npm install -g cordova).
  • iOS: cordova-ios 7.0.0 or later, Xcode 15 or later, and CocoaPods (sudo gem install cocoapods). iOS deployment target 15.1 or later.
  • Android: cordova-android 13.0.0 or later, Android Studio with SDK 34 or later, JDK 17. Recent Android Studio releases (Giraffe and later) ship the Gradle IntelliJ plugin only — install a standalone gradle binary and make sure it's on PATH, or cordova-android cannot bootstrap the project's Gradle wrapper.

Initial setup

  1. Add the plugin to your Cordova project. Run from your Cordova project root — the directory containing config.xml. This registers the plugin under the Cordova plugin ID co.acoustic.connect.push and adds window.AcousticConnect to your app's JavaScript context.
npx cordova plugin add cordova-acoustic-connect
npx cordova plugin add [email protected]
  1. Create ConnectConfig.json at your Cordova project root. Add your Connect credentials to the file.
{
  "Connect": {
    "AppKey": "<your-app-key>",
    "PostMessageUrl": "<your-collector-url>",
    "useRelease": false
  }
}
ConnectConfig.json field reference
FieldDescription
AppKeyRequired. Your Connect application key.
PostMessageUrlRequired. Your Connect collector endpoint.
useReleaseBoolean — npx cordova prepare fails if it isn't. Keep the default false during development; set to true before releasing. After the initial install, changing this value requires removing and re-adding the plugin (a plain cordova prepare won't pick it up). See Move your Cordova integration to production.
  1. Add ConnectConfig.json to .gitignore to keep your credentials safe.

  2. Run npx cordova prepare. On iOS, this runs pod install — no need to do it yourself, unless CocoaPods reports a stale spec repo (see Troubleshooting).

npx cordova prepare
🚧

Warning

On iOS, this step runs pod install, which generates a .xcworkspace file. From this point on, always open platforms/ios/App.xcworkspace — not .xcodeproj. Opening the .xcodeproj directly causes build failures because CocoaPods dependencies are only linked through the workspace.

  1. Add connect-config.js to index.html, after cordova.js. npx cordova prepare generates this file from ConnectConfig.json and exposes window.ConnectBasicConfig — reference it before your app's script:
<script src="cordova.js"></script>
<script src="js/connect-config.js"></script>
<script src="js/index.js"></script>
  1. Call AcousticConnect.enable() from your deviceready handler, before any other plugin method. Pass your credentials from window.ConnectBasicConfig so they stay defined in one place — ConnectConfig.json.
// At the top of www/js/index.js:
const CONFIG = window.ConnectBasicConfig || {};

// Enables the SDK from the bundled config.
document.addEventListener('deviceready', async function () {
  await AcousticConnect.enable(CONFIG.AppKey, CONFIG.PostMessageUrl);
}, false);
// In your app's entry file, before your framework mounts:
// Initialize the Connect SDK — deviceready fires when the Cordova bridge is ready.
document.addEventListener('deviceready', async function () {
  const config = window.ConnectBasicConfig;
  await AcousticConnect.enable(config.AppKey, config.PostMessageUrl);
}, false);

Verify the SDK is running

Step 1: Enable debug logging

In a Debug build with "useRelease": false in ConnectConfig.json (the default), verbose native logging from the SDK's Connect, Tealeaf, and EOCore modules is written to the Xcode console. To enable it, add the following environment variables to your scheme under Run → Arguments → Environment Variables:

VariableValue
CONNECT_DEBUG1
TLF_DEBUG1
EODebug1

A Release-configuration build won't produce verbose output, even with useRelease: false. For verbose logs, run a Debug build.

Step 2: Check the results

Run the app, then filter the Xcode console by Connect: to isolate the key SDK lifecycle events. Look for these entries to confirm the SDK is running:

EntryWhat it means
EOCore enabledCore layer initialized
killswitch : says liveKill switch check passed — SDK is active
Starting Tealeaf libraryConnect SDK starting
currentSessionId set to: ...Session created
tltsid = ( ... )Session ID assigned — SDK is tracking

The following entries are expected and safe to ignore:

EntryReason
EOCoreSettings bundle not foundExpected with programmatic config — no settings bundle needed
Value for key TLFInject:WKWebView:*Defaults being used, harmless
THREAD WARNING: ['ConnectPlugin']Performance note, not a failure
APNs device token registration failedExpected until push notifications are configured

On Premium and Ultimate plans, you can also confirm the session in Connect: go to Behavior analytics > Session intelligence and look for your test session.



Troubleshooting

pod install / npx cordova build ios fails: command not found: pod

CocoaPods isn't installed. Run sudo gem install cocoapods && pod repo update. On Apple Silicon, an outdated ffi gem can also break pod install — if gem install cocoapods itself fails, try sudo gem install ffi.

Undefined symbols / "Framework not found Pods_App" at build time

You opened platforms/ios/App.xcodeproj instead of the CocoaPods-generated workspace. Always open platforms/ios/App.xcworkspace after npx cordova prepare ios / npx cordova build ios.

CocoaPods platform-compatibility error naming AcousticConnect / AcousticConnectDebug

Your project's deployment-target is below the plugin's minimum of 15.1. Remove any config.xml override below 15.1, or raise it to at least 15.1.

CocoaPods LD_RUNPATH_SEARCH_PATHS override warnings

npx cordova prepare may produce warnings like:

[!] The `App [Debug]` target overrides the `LD_RUNPATH_SEARCH_PATHS` build setting defined in `Pods-App.debug.xcconfig`. This can lead to problems with the CocoaPods installation.

cordova-ios generates project.pbxproj with a hardcoded LD_RUNPATH_SEARCH_PATHS value that doesn't include $(inherited), so CocoaPods' xcconfig paths are silently overridden. Any manual fix in Xcode Build Settings is overwritten on the next npx cordova prepare. Apply the fix via an after_prepare hook instead so it persists across prepares:

module.exports = function (context) {
  const platforms = context.opts.platforms;
  if (platforms.length > 0 && !platforms.includes('ios')) return;

  const path = require('path');
  const fs   = require('fs');

  const pbxprojPath = path.join(
    context.opts.projectRoot,
    'platforms', 'ios', '<YourApp>.xcodeproj', 'project.pbxproj'
  );
  if (!fs.existsSync(pbxprojPath)) return;

  let src = fs.readFileSync(pbxprojPath, 'utf8');
  const PATTERN     = /LD_RUNPATH_SEARCH_PATHS = "(?!\$\(inherited\))([^"]+)";/g;
  const REPLACEMENT = 'LD_RUNPATH_SEARCH_PATHS = "$(inherited) $1";';
  if (!PATTERN.test(src)) return;

  PATTERN.lastIndex = 0;
  fs.writeFileSync(pbxprojPath, src.replace(PATTERN, REPLACEMENT), 'utf8');
};

Register it in config.xml under the iOS platform block:

<platform name="ios">
  <hook type="after_prepare" src="hooks/after_prepare_ld_runpath.js" />
</platform>

The hook patches the pbxproj on the first prepare and skips cleanly on subsequent runs.

"Unsupported Swift Version" dialog on opening the workspace

After running npx cordova prepare ios and opening the .xcworkspace, Xcode may present an "Unsupported Swift Version" dialog for the Connect plugin. This happens because cordova-ios doesn't set SWIFT_VERSION in the generated project.

Dismiss the dialog, then set the version manually: select the project in the Xcode navigator, go to Build Settings, search for Swift Language Version, and set it to Swift 5.


Next steps



Did this page help you?