GuidesDiscussions
Log In
Guides

Integrating the SDK

Introduction

  • DIGITALREEF's SDK is delivered as a zipped folder containing the following list of files :

    • DR SDK Android library (AAR file)
    • DR ID Android Library (AAR file)
    • Configuration's file 'drconfig.json"
    • iu-proguard.txt (Support file for obfuscation the codebase)
    • Amlibrary.java (Support file for Cordova invocation)
    • amlibrary.js (Support file for Cordova invocation)
  • Current version of DR SDK is 4.11.1

Integration Overview

The following diagram shows an overview of the integration process for the DR SDK.

Assumptions

Please note that DR SDK is of type implementation with the following Android API levels and dependencies:

compileSdkVersion 30
minSdkVersion 21
targetSdkVersion 30
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'

Android - 31

compileSdkVersion 31
minSdkVersion 21
targetSdkVersion 31
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'

📘

Compatibility

  • DR SDK has been tested and certified with version 31 or below.
  • DR SDK has been compiled using Java 1.8

Step 1: Extract the zip file

Extract the zip file share by DR team to an easily accessible folder to integrate with your project.

Step 1.1 [Optional] : Add Rich Notification watermark.

IU Rich Notification enables placement of a watermark image on the Rich Notification media. In-order for the watermark to be displayed, place the png image in the android folder and rename the as rich_notification_logo.png

Next, open the plugin.xml file present in the amlibrary folder and uncomment the line referring to rich_notification_logo.png

The directory structure would look like the image below:

Step 2 : Add the DR Amazonia plugin

Open the Command prompt(in windows) / Terminal (in Linux / Mac) and change directory to your project .

In command prompt / Terminal type the following command. Path would the place where you have extracted

ionic cordova plugin add <path-to-folder>\amlibrary
cordova plugin add <path-to-folder>\amlibrary

On successful completion of the add command you would be able to see a message similar to the following

Installing "cordova-plugin-iu-amlibrary" for android
Subproject Path: CordovaLib
Subproject Path: app
Adding cordova-plugin-iu-amlibrary to package.json

🚧

Remove idmanager.aar

If you have integrated the DR SDK earlier to 4.7.1 with idmanager.aar file, you wil have to remove the same from libs folder to avoid the conflicts during compilation.

idmanager, has bee completely integrated inside the v4.7.1 version of the DR SDK.

Step 3 : Manifest Changes

3.1 Disabling the backup

In the AndroidManfest.xml file, kindly set the allowBackup to false in the Application tag.

<application
    android:allowBackup="false"
    android:fullBackupContent="@xml/backup_descriptor"

Sample backup_descriptor code is below. Place it in res\xml\ folder.

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

3.2 Allowing HTTP traffic from the APP

Please add the following line of code to Application tag in AndroidManifest.xml.  This would enable the API call for Head enrichment to receive phone number on the IU servers.

Path to AndroidManifest : <path of project>/platforms/android/app/src/main/AndroidManifest.xml

android:usesCleartextTraffic="true"

3.3 Permissions for Querying installed applications list

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

🚧

If QUERY_ALL_PACKAGES is added to manifest

If QUERY_ALL_PACKAGES is added to manifest then you would to declare this permission and follow the steps while uploading the build to Google Play Store. This step is mandatory and FULLY the app's responsibility.

(Link : https://support.google.com/googleplay/android-developer/answer/9214102?hl=en)

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

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

📘

Google Policy

Note that if you choose to access user's installed apps, it is mandatory that a runtime permission is added to your app letting the end user know about the collection, its purpose, and allowing for an opt-out. The Data Disclosure dialog can be used for such runtime permission.

3.4 REQUEST_INSTALL_PACKAGE Permission (Optional)

DR SDK contains REQUEST_INSTALL_PACKAGE permission for all the versions below v4.11.1 (including v4.11.0).

Please check if your app falls into any of the following categories:

  • Web browsing or search;
  • Communication services that support attachments;
  • File sharing, transfer or management;
  • Enterprise device management.
  • Backup & restore
  • Device Migration / Phone Transfer

If the app is not apart of the above category It would be advisable to remove it from the AndroidManifest.xml with help of the code below.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="your.package.com">
      
      <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"  tools:node="remove"/>
      
</manifest>

DR SDK with v4.11.1 and above will have this permission removed.

3.5 Support for Ad-Mob SDK (Optional)

In case the host application is already having Ad-Mob SDK and related Meta data in manifest, we are likely to see the error which looks similar to one as shown below:

Merging Errors: Error: Attribute meta-data#com.google.android.gms.ads.APPLICATION_ID
@value value=(ca-app-pub-8647026263512754~4219912420) from AndroidManifest.xml:33:13-67 
is also present at AndroidManifest.xml:240:13-67 value=(ca-app-pub-8647026263512754~
4219312429). Suggestion: add 'tools:replace="android:value"' to <meta-data> element 
at AndroidManifest.xml:31:9-34:15 to override. IUAmazonia.iutestapp main manifest 
(this file), line 32

On receiving this error, please add the following attribute into the manifest tag on the top of the file

xmlns:tools="http://schemas.android.com/tools"

Final manifest tag will look similar to one below:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
          xmlns:tools="http://schemas.android.com/tools"
          ...
          >

Add the following tag to Ad-Mob meta-data tag

tools:replace="android:name, android:value"

Sample of final <meta-data> tag would be look similar to the code as below:

<meta-data
    android:name="com.google.android.gms.ads.APPLICATION_ID"
    android:value="ca-app-pub-8647026263512754~4219912420"
    tools:replace="android:name, android:value" />

3.5 Add HostComplianceActivity to Manifest

To comply with Google policies of having the Host application in background when showing the Ads, we would need an Activity. We have implemented a default Activity which is part of the ZIP file and would be copied to the project. We need to add the same to Manifest file. Use the below text and paste in AndroidManifest.xml file.

<activity
  android:name="com.iu.amlibrary.HostComplianceActivity"
  android:autoRemoveFromRecents="true"
  android:excludeFromRecents="true"
  android:exported="true"
  android:launchMode="singleTask" />

If you wish to customise the look and feel of the activity, please refer to Google Compliant Activity section.

3.6 Request for Notification Permissions

Needed for App targeting API 33 (Android 13 or Android T)

If your app is targeting Android API 33 (Android 13) then the App should request for Push Notification permission to display them, else no Notification can be shown.

For DR SDK to function better, we would need Push Notification to be available. If your app is requesting the information, you may skip to Step 3.

If DR SDK is going to handle the Push Notification Permission then add the following to your AndroidManifest.xml file.

<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

If your app would like to control when to show the Push Notification Permission, you can do so by calling the following method of DR SDK.

IUApp.requestNotificationPermission(Context context, NotificationPermissionListener listener)

// Context - Activiity Context

// NotificationPermissionListener - Interface which needs to be implimented in the host app 
// to check for the boolean response of True or Flase. Will be true when granted, 
// false when denied.

Sample call to invoke Notification Permission request through DR SDK

IUApp.requestNotificationPermission(this, granted -> {
    // result..
    String text = granted ? "GRANTED" : "NO PERMISSION";
    Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
});

Optionally, DR SDK can request the permission on initialisation of DR SDK. (Based on flag)