Cordova

Add Fload's attribution plugin to a Cordova app. One plugin covers iOS and Android. It calls Fload's native SDKs underneath, so it behaves exactly like them.


What you need

  • cordova-ios 8 or later, and cordova-android 13 or later.
  • iOS 15 or later, and Android API 24 or later.
  • Your app's write key.
  • RevenueCat's Cordova plugin, cordova-plugin-purchases, in your app, if you want revenue per keyword. Fload's plugin doesn't depend on it.

1. Add the plugin

bash
cordova plugin add @fload-ai/attribution-cordova

Set the iOS deployment target in config.xml:

xml
<platform name="ios">
    <preference name="deployment-target" value="15.0" />
</platform>

Nothing to add on Android: the plugin adds the JitPack repository and the native SDK itself. TypeScript types come with the plugin.


2. Start it once the device is ready

Plugins are ready after deviceready. Call FloadAttribution.configure there, once.

js
document.addEventListener('deviceready', async () => {
  Purchases.configureWith({
    apiKey: cordova.platformId === 'ios' ? 'appl_…' : 'goog_…',
  });

  await FloadAttribution.configure({ key: 'fload_pk_…' });
  Purchases.getAppUserID((appUserID) => {
    FloadAttribution.setUserId({ id: appUserID });
  });
}, false);

When a user logs in, RevenueCat's id changes. Call FloadAttribution.setUserId({ id }) again with the new one.


3. Check it works

Turn on debug logs while you test:

js
await FloadAttribution.configure({ key: 'fload_pk_…', logLevel: 'debug' });

Run on a real iPhone and a real Android phone, and look for the native logs: the subsystem com.fload.attribution on iOS, and the Logcat tag FloadAttribution on Android. Remove the debug option before you ship.


4. Ship it

Ship a new store build. Fill in Privacy for both stores.


Reference

CallWhat it does
FloadAttribution.configure({ key, logLevel? })Starts the SDK. Call once, after deviceready. logLevel is 'none', 'error', 'warning' (the default), 'info' or 'debug'
FloadAttribution.setUserId({ id })Links your user id to this install
FloadAttribution.getInstallReference()Resolves to { installReference }: this install's random reference, for support questions

Every call returns a Promise.

The plugin uses version 1.0.2 of the native Android SDK. To pin another 1.x version, add the plugin with --variable FLOAD_ATTRIBUTION_ANDROID_VERSION=….

Can't add a plugin? You can send installs from your own native code with the HTTP API. You then own the hard parts: getting Apple's token on the first launch, sending it within 24 hours, and retrying.

Source code and changelog: github.com/fload-ai/fload-attribution-cordova.