GuidesDiscussions
Log In
Guides

Integrating the SDK

Introduction

  • DIGITALREEF's SDK is delivered as a maven dependency.

  • DIGITALREEF's SDK includes a configuration file called drconfig.json, which configures the SDK behavior for a specific integration. This file will be provided by your DigitialReef contact.

  • The current version of the DR SDK is 4.15.3.

Integration Overview

The following diagram provides an overview of the integration process for the DR SDK:

Step 1: Update gradle.properties file

  1. Open the gradle.properties file.

  2. Add the following line to the end of the file:

    authToken=jp_s8qni57qrp5tcj393ladaqi85
    

Step 2: Update build.gradle for maven repository

  1. Open the project-level build.gradle file.

  2. Update the maven repository to include the DR SDK.

  3. Ensure that both google() and jcenter() are configured as repositories.

  4. Add com.google.gms:google-services as a dependency.

  5. Sample build.gradle content:

    buildscript {
      repositories {
        google()
        jcenter()
      }
      dependencies {
        classpath 'com.android.tools.build:gradle:4.1.3'
        classpath 'com.google.gms:google-services:4.3.10' // Google services dependency for DR FCM
      }
    }
    allprojects {
      repositories {
        google()
        jcenter()
        maven { 
          url "https://jitpack.io" 
          credentials {username authToken}
        }
      }
    }
    

Step 3: Include necessary Gradle Dependencies and AndroidManifest attributes

Assumptions

  • DR SDK uses implementation type with the following Android API levels and dependencies:

    compileSdkVersion 33
    minSdkVersion 21
    targetSdkVersion 33
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    
  • Delete any existing version of the IU/DR SDK .aar file from the libs directory.

3.1 Add Gradle dependencies

  1. Add the following dependencies to the app module's build.gradle:

    dependencies {
        // Your app's dependencies
        implementation 'com.github.Digita1Reef.IUAmazonia:<variant>:<version>' // DR AAR File
        implementation 'com.google.code.gson:gson:2.8.9' // GSON
        implementation 'androidx.room:room-runtime:2.4.1' // Room
        annotationProcessor 'androidx.room:room-compiler:2.4.1'
        implementation 'com.squareup.okhttp3:okhttp:4.9.3' // OK Http
        implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0' // Dynamic Animation
        implementation 'com.google.android.gms:play-services-ads:20.5.0' // Google Play library for obtaining the Android ID
        implementation 'com.google.android.gms:play-services-location:19.0.1' // Geofence Play library for obtaining the Location
        implementation platform('com.google.firebase:firebase-bom:29.0.4') // FCM Dependencies
        implementation 'com.google.firebase:firebase-config'
        implementation 'com.google.firebase:firebase-analytics'
        implementation 'com.google.firebase:firebase-core'
        implementation('com.google.firebase:firebase-messaging') {
          exclude group: 'org.json', module: 'json'
        }
        implementation "androidx.work:work-runtime:2.7.1" // WorkManager
    }
    

    ℹ️

    Variant and Version: Obtain the Variant and Version of the SDK from your contact as per your feature set requirements.

3.2 Add the Google Services plugin

  1. If it doesn't exist, add the following plugin to the app module's build.gradle:

    apply plugin: 'com.google.gms.google-services'
    

    ⚠️

    This may cause a Gradle Sync error if you don't have an existing google-services.json file, but it will be resolved later.

  2. Update the root-level build.gradle file as well:

    buildscript {
      repositories {
        google()
        jcenter()
      }
      dependencies {
        classpath 'com.android.tools.build:gradle:4.1.3'
        classpath 'com.google.gms:google-services:4.3.10' // Google services dependency for DR FCM
      }
    }
    allprojects {
      repositories {
        google()
        jcenter()
      }
    }
    

3.3 Disable Backup

  1. Add the following code to the AndroidManifest.xml file within the <application> tag:

    <application
        android:allowBackup="false"
        android:fullBackupContent="@xml/backup_descriptor" ...>
      ...
    </application>
    
  2. Create the backup_descriptor.xml file in the res/xml/ folder with the following content:

    <?xml version="1.0" encoding="utf-8"?>
    <full-backup-content>
        <exclude
            domain="sharedpref"
            path="IU_AMAZONIA.xml" />
    </full-backup-content>
    

3.4 Permissions for Querying installed applications list

⚠️

[DEPRECATED] With Android 11 and above, apps are restricted from reading other installed applications (link: https://support.google.com/googleplay/android-developer/answer/10158779?hl=en).

  1. If you still need to collect installed apps, add the following snippet to your Android Manifest:

    <queries>
        <intent>
            <action android:name="*" />
        </intent>
    </queries>
    

    ⚠️

    Note that if you choose to access user-installed apps, it is mandatory to add a runtime permission to your app, informing the user about the collection, its purpose, and allowing them to opt out. The Data Disclosure dialog can be used for this runtime permission.

3.5 Support for AdMob SDK (Optional)

If your host application already has the AdMob SDK, refer to the AdMob support section.

3.6 Add ProGuard exception rules

⚠️

If you have minifyEnabled true, make sure to add the following ProGuard rules to ensure all SDK services work correctly.

Add the following lines to your proguard-rules.pro file:

-keepattributes Signature 
-keepattributes InnerClasses 
-keepclassmembers enum * {
  public static **[] values(); 
  public static ** valueOf(java.lang.String); 
}
-keep class amazonia.iu.com.amlibrary.client.IUConfig { *; }
-keep class amazonia.iu.com.amlibrary.data.** { *; }
-keep class amazonia.iu.com.amlibrary.dto.** { *; }
-keep class amazonia.iu.com.amlibrary.config.AppStateManager { *; }
-keep class amazonia.iu.com.amlibrary.cache.BaseStorageCache$** { *;} 
-keep class amazonia.iu.com.amlibrary.diagnostics.Command { *; }
-keep class amazonia.iu.com.amlibrary.diagnostics.Command$** { *; } 
-keep class amazonia.iu.com.amlibrary.instructions.Instruction { *; } 
-keep class amazonia.iu.com.amlibrary.instructions.Instruction$** { *; } 
-keep class android.content.pm.IPackageInstallObserver {*; }
-keep class amazonia.iu.com.amlibrary.actions.silent.SilentInstallAppFromServerFactory { *; } 
-keep class amazonia.iu.com.amlibrary.vas.VasInfo {*; }
-keep class amazonia.iu.com.amlibrary.vas.VasAcknowledgementDTO {*; }
-keep class amazonia.iu.com.amlibrary.vas.VasRequestDTO {*;}
-keep class amazonia.iu.com.amlibrary.vas.VasResponse {*;}
-keep class amazonia.iu.com.amlibrary.client.IUApp {*;}
-keep class amazonia.iu.com.amlibrary.activities.fragment.VideoPlayerFragment{*;}
-keep class amazonia.iu.com.idmanager.dto.** { *; }
-keep class amazonia.iu.com.amlibrary.client.OTAPromotionReceiverListener { *; }
-keep class amazonia.iu.com.amlibrary.client.NotificationsListener { *; }
-keep class amazonia.iu.com.amlibrary.client.OtaEvent { *; }

3.8 Request Notification Permissions

Required for apps targeting API 33 (Android 13 or Android T)

If your app targets Android API 33 (Android 13), it should request push notification permission to display them. Otherwise, no notifications can be shown.

To enable Push Notification permission handling by DR SDK:

  1. Add the following permission to your AndroidManifest.xml file:

    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
    
  2. Optionally, if you want to control when to show the Push Notification Permission, you can call the following method in your activity:

    IUApp.requestNotificationPermission(Context context, NotificationPermissionListener listener)
    
    • Context: Activity Context.
    • NotificationPermissionListener: Interface implemented in the host app to receive the boolean response (true for granted, false for denied) and handle it accordingly.

    Here's a sample call to request notification permission using DR SDK from an activity:

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // ...
        boolean askPermission = // your business rule
        if (askPermission) {
            IUApp.requestNotificationPermission(this, granted -> {
                askPermission = granted;
                // your business rule
            });
        }
    }
    

Step 4: Add the DR Customer Configurations

4.1 Add the DR Config file

  1. Copy the drconfig.json file, provided by your DigitialReef contact, to the assets folder of your application.

For more details on individual drconfig.json configurations, refer to Appendix A.