Support Home > SDK Integration > Cordova – SDK Integration

Cordova – SDK Integration

The Kochava Cordova SDK is a lightweight plugin which can be easily integrated into your Cordova project. The entire integration process takes less than five minutes and simply requires adding the SDK within your project and then starting the Kochava Tracker in code. If you have already integrated the SDK and started the tracker, please visit Using the SDK and choose a topic.

 

Integration Note: If targeting Android 13, collection of the ADID requires the normal permission:
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/> Please ensure this permission is added to your AndroidManifest.xml in order for ADID collection to continue to take place as of Android 13 and beyond.
Some Google Play policies, such as the Families Policy, require that apps not use the ADID. In those cases this permission should not be included as the ADID should not be collected.


Integrating the SDK

Requirements:

  • Android API 16
  • iOS Target 10.3
  • Xcode 13.3.1

 

Supported Platforms:

  • Android
  • iOS

Migration:

If you are migrating from a Kochava SDK prior to version 3.0.0 to version 3.x first remove the old version by running the following command from the root of your project.

Once removed the new version can be integrated by following the integration steps below. SDK usage can then be updated by reviewing the code samples for any given topic, as the overall usage of the SDK remains the same.


Integration:

Estimated Time to Complete
5 Minutes

(Release Notes)

In order to use the Kochava SDK you must first add it to your project.

  1. Download and unzip the Kochava Cordova SDK to a known location.
  2. Using a terminal navigate to the root directory of your Cordova Project.
  3. Run the following command where sdk_path is the location of the unzipped Kochava Cordova SDK from step 1.

Google Play Store:

If you wish for the SDK to collect the Google Play Ads Identifier (ADID), App Set ID (ASID) and/or make use of the Install Referrer, you must integrate Google Play Services by adding the appropriate dependencies. Collection is handled by the Kochava SDK with only the dependency itself needing to be included. The Kochava SDK does not require specific versions of its dependencies however we recommend keeping them up to date whenever possible.

 

Maven Repository —

google()

 

Dependencies —

Ads Identifier

implementation 'com.google.android.gms:play-services-ads-identifier:17.1.0'

NOTE: If using a version prior to version 17.1.0 you must also add the following permission.

<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

 

Install Referrer

implementation 'com.android.installreferrer:installreferrer:2.2'

 

App Set ID

implementation 'com.google.android.gms:play-services-appset:16.0.0'

Huawei App Gallery:

If you wish for the SDK to collect the Huawei Advertising ID (OAID) and/or make use of the Install Referrer, you must integrate the Huawei Ads SDK by adding the appropriate dependencies. Collection is handled by the Kochava SDK with only the dependency itself needing to be included. The Kochava SDK does not require specific versions of its dependencies however we recommend keeping them up to date whenever possible.

 

Maven Repository —

maven { url 'https://developer.huawei.com/repo/' }

 

Dependencies —

Ads Identifier

implementation 'com.huawei.hms:ads-identifier:3.4.39.302'

 

Install Referrer

implementation 'com.huawei.hms:ads-installreferrer:3.4.39.302'

Permissions:

The following permissions are split by module and are automatically included with the module. Optional permissions are noted and can be removed if desired using the manifest entry shown.

// Tracker Module
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

// Optionally remove the automatically included Network State permission.
<!-- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" tools:node="remove"/> -->


// Network Module
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

// Optionally remove the automatically included Wifi State permission.
<!-- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" tools:node="remove"/> -->

 

Minification (ProGuard / R8):

The following minification rules are required when code minification is enabled. They are automatically included when adding the Kochava SDK and typically do not require manual inclusion. If you are experiencing issues after enabling minification you can manually include the rules in your configuration file.

# KochavaCore: Ignore SDK warnings for missing dependencies.
-dontwarn com.kochava.core**

# KochavaCore: Uncomment only if needed. Do not run ProGuard on the SDK at all.
#-keep class com.kochava.core** { *; }

# KochavaCore: Keep annotations used for json serialization.
-keepattributes Signature
-keepattributes *Annotation*
-keepclassmembers class * {
  @com.kochava.core.json.annotation.internal.JsonSerialize ;
}
-keepclassmembers class * {
  @com.kochava.core.json.annotation.internal.JsonIgnore ;
}
-keepclassmembers class * {
  @com.kochava.core.json.annotation.internal.JsonEnumSerializedValue ;
}

# KochavaCore: BuildConfig
-keep class com.kochava.core.BuildConfig { *; }

# KochavaCore: Google Instant Apps Collection.
-keep class com.google.android.gms.common.wrappers.InstantApps {
    boolean isInstantApp(android.content.Context);
}

# KochavaTracker: Ignore SDK warnings for missing dependencies.
-dontwarn com.kochava.tracker**

# KochavaTracker: Uncomment only if needed. Do not run ProGuard on the SDK at all.
#-keep class com.kochava.tracker** { *; }

# KochavaTracker: BuildConfig
-keep class com.kochava.tracker.BuildConfig { *; }

# KochavaTracker: Google ADID Collection.
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
    com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
    java.lang.String getId();
    boolean isLimitAdTrackingEnabled();
}

# KochavaTracker: Google Install Referrer Collection.
-keep class com.android.installreferrer.api.InstallReferrerClient { *; }
-keep class com.android.installreferrer.api.InstallReferrerClient$InstallReferrerResponse { *; }
-keep class com.android.installreferrer.api.InstallReferrerStateListener { *; }
-keep class com.android.installreferrer.api.ReferrerDetails { *; }

# KochavaTracker: Google App Set ID Collection
-keep class com.google.android.gms.appset.AppSet {
    com.google.android.gms.appset.AppSetIdClient getClient(android.content.Context);
}
-keep class com.google.android.gms.appset.AppSetIdClient {
    com.google.android.gms.tasks.Task getAppSetIdInfo();
}
-keep class com.google.android.gms.appset.AppSetIdInfo {
    java.lang.String getId();
    int getScope();
}
-keep class com.google.android.gms.tasks.Tasks {
    await(com.google.android.gms.tasks.Task, long, java.util.concurrent.TimeUnit);
}

# KochavaTracker: Huawei OAID Collection.
-keep class com.huawei.hms.ads.identifier.AdvertisingIdClient {
    com.huawei.hms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
}
-keep class com.huawei.hms.ads.identifier.AdvertisingIdClient$Info {
    java.lang.String getId();
    boolean isLimitAdTrackingEnabled();
}

# KochavaTracker: Huawei Install Referrer Collection.
-keep class com.huawei.hms.ads.installreferrer.api.InstallReferrerClient { *; }
-keep class com.huawei.hms.ads.installreferrer.api.InstallReferrerClient$InstallReferrerResponse { *; }
-keep class com.huawei.hms.ads.installreferrer.api.InstallReferrerStateListener { *; }
-keep class com.huawei.hms.ads.installreferrer.api.ReferrerDetails { *; }

# KochavaTracker: Notifications Enabled Collection.
-keep class androidx.core.app.NotificationManagerCompat {
    static androidx.core.app.NotificationManagerCompat from(android.content.Context);
    boolean areNotificationsEnabled();
}

# KochavaTrackerEvents: Ignore SDK warnings for missing dependencies.
-dontwarn com.kochava.tracker.events**

# KochavaTrackerEvents: Uncomment only if needed. Do not run ProGuard on the SDK at all.
#-keep class com.kochava.tracker.events** { *; }

# KochavaTrackerEvents: BuildConfig
-keep class com.kochava.tracker.events.BuildConfig { *; }

# KochavaTrackerEvents: Internal SDK
-keep class com.kochava.tracker.events.Events {
    static com.kochava.tracker.events.EventsApi getInstance();
    void setController(com.kochava.tracker.modules.events.internal.EventsControllerApi);
    com.kochava.tracker.modules.events.internal.EventsControllerApi getController();
}

# KochavaTrackerEngagement: Ignore SDK warnings for missing dependencies.
-dontwarn com.kochava.tracker.engagement**

# KochavaTrackerEngagement: Uncomment only if needed. Do not run ProGuard on the SDK at all.
#-keep class com.kochava.tracker.engagement** { *; }

# KochavaTrackerEngagement: BuildConfig
-keep class com.kochava.tracker.engagement.BuildConfig { *; }

# KochavaTrackerEngagement: Internal SDK
-keep class com.kochava.tracker.engagement.Engagement {
    static com.kochava.tracker.engagement.EngagementApi getInstance();
    void setController(com.kochava.tracker.modules.engagement.internal.EngagementControllerApi);
    com.kochava.tracker.modules.engagement.internal.EngagementControllerApi getController();
}

# KochavaTrackerDatapointNetwork: Ignore SDK warnings for missing dependencies.
-dontwarn com.kochava.tracker.datapointnetwork**

# KochavaTrackerDatapointNetwork: Uncomment only if needed. Do not run ProGuard on the SDK at all.
#-keep class com.kochava.tracker.datapointnetwork** { *; }

# KochavaTrackerDatapointNetwork: BuildConfig
-keep class com.kochava.tracker.datapointnetwork.BuildConfig { *; }

# KochavaTrackerDatapointNetwork: Internal SDK
-keep class com.kochava.tracker.datapointnetwork.internal.DataPointCollectionNetwork {
    public ;
}

# KochavaTrackerLegacyReferrer: Ignore SDK warnings for missing dependencies.
-dontwarn com.kochava.tracker.legacyreferrer**

# KochavaTrackerLegacyReferrer: Uncomment only if needed. Do not run ProGuard on the SDK at all.
-keep class com.kochava.tracker.legacyreferrer** { *; }

# KochavaTrackerLegacyReferrer: BuildConfig
-keep class com.kochava.tracker.legacyreferrer.BuildConfig { *; }

# KochavaTrackerLegacyReferrer: Referrer Receiver
-keep class com.kochava.tracker.legacyreferrer.LegacyReferrerReceiver {
    onReceive(android.content.Context, android.content.Intent);
}

 
 


Starting the Tracker

Estimated Time to Complete
1 Minute

Once you have added the Kochava SDK to your project, the next step is to configure and start the Kochava Tracker in code. Only your App GUID is required to start the tracker with the default settings, which is the case for typical integrations.

We recommend starting the tracker as soon as the application starts, although this can be done later if needed. Starting the tracker as early as possible will ensure it’s started before use, provide more accurate session reporting, and quicker deeplink results.

 


Confirm the Integration

After integrating the SDK and adding the code to start the tracker, launch and run the app for at least 10 seconds or more. During this time the tracker will start and send an install payload to Free App Analytics. To confirm integration was successful, visit the app’s Install Feed Validation page Apps & Assets > Install Feed Validation. On this page you should see one of two integration messages, indicating integration success or failure.

 

Integration Successful:

 Integration Success!

 

Along with this message you will also see a variety of data points associated with the device used for testing. At this point your integration is successful and you can proceed to the next step(s).

NOTE: It may take a few minutes for the first install to appear within the Install Feed Validation page. If you do not see this message immediately, you may simply need to wait a few minutes and check again.


Integration Not Complete:

 Integration Not Complete!

 

If you encounter this message, please review the integration steps, uninstall and reinstall the app, and check again.

 
 

 

SDK WAYPOINT: At this point basic integration is complete and the Kochava SDK will begin reporting session activity and attributing installs.

 

Where to Go From Here:

Now that you have completed integration you are ready to utilize the many features offered by the Kochava SDK. Continue on to Using the SDK and choose a topic.

 
 

Last Modified: Jul 26, 2022 at 1:34 pm