Android

SDK is available as a library in AAR (recommended) and JAR. The library is available in Maven Central repository and on GitHub repository.

Step 1. If you use Gradle for the applications build, add mavenCentral() into gradle.build file of your application and specify the following relationship in dependencies block:

dependencies {
    implementation 'com.devtodev:android:1.14.10'
    implementation 'com.android.installreferrer:installreferrer:2.2'
    implementation 'com.google.android.gms:play-services-base:17.6.0'
    implementation 'com.google.firebase:firebase-core:19.0.0'
    implementation 'androidx.preference:preference:1.1.1' //or higher, required for SDK version 1.14.8 and higher
}

In case you don't use Gradle, you can download it here and add the library into the project.

Step 2. Initialize the library in the first Activity method onCreate() in the following way:

public class MyActivity extends Activity {
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          // Initialization devtodev SDK
          DevToDev.init(this, APP_ID, SECRET_KEY);
      }
}

App ID and Secret key can be found in the application settings: "Settings" → "SDK" → "Integration".

The devtodev analytics library contains an implementation of FirebaseMessagingService for working with push notifications. If you want to use your own or a third-party push notification service instead of implementing “devtodev push notification”, then you need to disable the built-in service in the manifest file.

Example:

<service
android:name="com.devtodev.push.logic.DTDFcmMessagingService"
android:enabled="false">
</service>

If you want to use our SDK to work with push notifications, see this doc.

Step 3. Add the following lines at the bottom of proguard.config

-keep class com.devtodev.** { *; }
-dontwarn com.devtodev.**

Additional initialization

If the application you integrate SDK in is a part of a cross-platform project, then the user data initialization is required.

Since the analytics of cross-platform projects is based on a unique user (unlike the usual projects where it is based on device identifiers), you have to:

  • Set the unique cross-platform user identifier (it will be used for cross-platform project data collection).

  • Actualize the user data. Mostly it is about game applications where the player has a game level as a characteristic. For such projects you need to set the current player level.

We recommend you set the user identifier before SDK initialization, otherwise, the user identifier from the previous session will be used since the SDK initialization moment till the setUserID method call.

If your cross-platform application is supposed to be used without cross-platform authorization, don't use the setUserID method or use the empty string ("") as the user identifier. SDK will assign the unique identifier to the user. This identifier will be used until the real cross-platform identifier assigns to the user.

/**
* Method allows to initialize the user. It applies when SDK initialization or user relogin.
* @param String activeUserId - unique cross-platform user identifier (max. 64 symbols)
*/
DevToDev.setUserId(activeUserId);

/**
* Method sets the current user level. Using this method allows to actualize the SDK user data
* in game cross-platform applications.
* @param int level - number of current game level of the user
*/
DevToDev.setCurrentLevel(currentLevel);

/**
* devtodev SDK initialization
* @param String appId - devtodev App Id
* @param String secretKey - Secret key
* devtodev App Id and Secret key can be found in the devtodev application
* settings page ("Settings" → "SDK" → "Integration")
*/
DevToDev.init(getBaseContext(), appId, secretKey);

If your application allows user to re-login (changing the user during the working session of application), then the setUserID and setCurrentLevel methods should be called just after the authorization. You don't need to call the SDK initialization one more time.

Debug mode

To enable the debug mode and make SDK notifications displayed in the console use this method:

/**
* @param logLevel
*/
DevToDev.setLogLevel(LogLevel logLevel);

Last updated