CMP + APP MONETISATION SDK INTEGRATION


In this detailed guide, we take you through the steps required to integrate the library with your Android and iOS app.
  GETTING THE INTEGRATION KEY
 
STEP 1 - After a legal contract has been signed between the Publisher and Quadrant, an invitation will be sent to Publisher’s email redirecting them to register to the platform.
 
Screenshot 2020-12-23 at 20.40.04
 
STEP 2 - Register on the Quadrant Publisher Platform
 
2-Jul-01-2021-06-22-46-69-AM
 
STEP 3 - Once you're logged in, click PUBLISHER DASHBOARD from the menu on the left. This will display your publisher dashboard.
 
3-Jul-01-2021-06-25-30-83-AM
 
STEP 4 - Add your App, and choose 'Location + Consent' as SDK type, select your desired OS Type, fill in all the required fields, and submit. What you fill in is what you will see in the consent form later in the app integrated with SDK.
 
c3
 
STEP 5 - Once submitted, your app will be enlisted, but the Integration key will not be displayed yet. At this point, you require an admin's approval. The admin will be automatically notified and can take the needful action.
 
5
 
STEP 6 - Once approved, your integration key will be displayed on the dashboard. You need to distribute this integration key to your app developers.
 
c4

INTEGRATING BOTH SDK - SETUP GRADLE, DEPENDENCIES REPO - ANDROID

STEP 1 - In Android Studio, open build.gradle of the app (the project level), and add codes as highlighted in yellow:
c5

INTEGRATING THE MONETIZATION (LOCATION) SDK - ANDROID

1. Open build.gradle of the app (the app specific level), and add this under 'dependencies' code section (highlighted in yellow):

implementation 'io.quadrant.sdk.locationdata:data-acquisition-sdk:<latest version>'

Latest version: 1.0.2

A2

STEP 2 - Sync the gradle files, now let’s try calling the setup method for initiating the monetisation SDK, fill in INTEGRATION_KEY with the integration key fetched from the dashboard.

Thats it!

If you try accessing a method from the library in your code, it should work.

Client.getInstance().setup(MainActivity.this, true, false, INTEGRATION_KEY, new Client.ResultCallback() {
@Override
public void onSuccess(String result) {
//start location data collection
}

@Override
public void onError(String result) {
//add error condition/ alert
}
});

Example:

 Screenshot 2021-06-25 at 15.29.58 (1)
 
Congratulations! You have successfully integrated the library into your android project!

TRACKING LOCATION - ANDROID

The library requires three permissions to run properly. Declare them in your app manifest.xml file.
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

And to start collecting, call this method:

Client.getInstance().startTrackingLocation();

 


Make sure to call the above method inside onSuccess() callback method of Client.getInstance().setup() that we declared before. As shown below:
 
Screenshot 2021-06-25 at 15.41.46

to stop tracking, and reenable tracking, there is a toggle functionality:

Client.getInstance().toggleStartTrackingLocation(false);

set the param to false to stop collecting the location tracking, set true to reenable location tracking

Congratulations! You have now configured everything required for location tracking!

 

INTEGRATING THE CONSENT MANAGEMENT SDK - ANDROID

STEP 1 - In Android Studio, open build.gradle of the app (the project level), and add codes as highlighted in yellow:
c5
STEP 2 - Open build.gradle of the app (the app-specific level), and add this under the 'dependencies' code section (highlighted in yellow):
 
implementation 'io.quadrant.sdk.compliance:compliancesdk:<latest version>'

Latest version: 1.0.11

c6
STEP 3 - Still under build.gradle of the app, add this under 'defaultConfig' code section (highlighted in yellow):
 
multiDexEnabled true c7
STEP 4 - Sync the gradle files, now let’s try calling the setup method for initiating the consent Management SDK, fill in INTEGRATION_KEY with the that you fetched from the dashboard.
 
and that's it!
 
If you try accessing a method from the library in your code, it should work.
 
1. private Compliance compliance;
2. compliance Compliance.getInstance(INTEGRATION_KEY);
 
Displaying GDPR/ CCPA Form

This method will automatically detect which form to show depending on the app user’s position (if they are in Europe they will be shown the GDPR form, if they are in California, they will be shown the CCPA form, in all other cases no form will be displayed):

1 compliance.openConsentFormIfNeeded(this, getSupportFragmentManager());
 
And it is recommended that the form is called when the Location permission is granted because it will detect the users position as mentioned above.

Example:

1

2

3

if(PermissionUtil.accessLocation(this)){

compliance.openConsentFormIfNeeded(this, getSupportFragmentManager());

}

and the PermissionUtil class , example will look like similar to this (and for Kotlin it can be slightly adjusted):

public class PermissionUtil {
public static final int PERMISSION_ACCESS_LOCATION = 111;

public static boolean accessLocation(Context context){
boolean permission;
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
if(ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED){
permission = false;
ActivityCompat.requestPermissions((Activity) context, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSION_ACCESS_LOCATION);
}else{
permission = true;
}
}else{
permission = true;
}
return permission;
}
}

 

GDPR Form:

compliance.openConsentForm(getSupportFragmentManager(),Compliance.GDPR)

CCPA Form:

compliance.openConsentForm(getSupportFragmentManager(),Compliance.CCPA)

Sample GDPR Form:

GDPR sample screens

Fetching the TCFString (GDPR TCF String & CCPA US Privacy String) Function

After the user accept / consent, the TCF string is stored both in server and the app itself. So basically we can get the stored locally TCF String by calling the function:

1compliance.getTCFString(this); // For GDPR 2compliance.getUSPrivacyString(this);// For CCPA

with this is the Context of the Activity.

Calling Compliance Request Function

fill in REQUEST_TYPE with below options:

Compliance.REQUEST_OPTOUT

Compliance.REQUEST_DO_NOT_SELL

Compliance.REQUEST_DELETE_DATA → will display a delete request popup form

Compliance.REQUEST_ACCESS_DATA will display a request data popup form

compliance.initComplianceRequest(MainActivity.this, MainActivity.this.getSupportFragmentManager(), 
REQUEST_TYPE, new Compliance.ResultCallback(){
@Override
public void onSuccess(String result) {
//to do if request is successful
}

@Override
public void onError(String result) {
//to do if request is failed/error
}
});

Sample Compliance Request (Delete and Request Data form):

 

Sample Compliance Request (Delete and Request Data form)

INTEGRATING THE CONSENT MANAGEMENT SDK - iOS

STEP 1 - Installation using Cocoapods

Add this line in your Podfile:

pod_link TBD

pod "QCMP_SDK", :git => 'pod_link'

and then install by type pod install in your command line

 

STEP 2 - Setup integration key

Register your integration key after app launch, usually your AppDelegate.swift

  • import QCMP_SDK to use this framework

  • Set up your integration key and error handle in didFinishLaunchingWithOptions 

    • import QCMP_SDK GIBB

      @UIApplicationMain
      class AppDelegate: UIResponder, UIApplicationDelegate {

      let compliance = Compliance.shared
      let integrationKey: String = "your integration key here"

      func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
      compliance.setup(integrationKey)
      }
      }
    • USING THE CONSENT MANAGEMENT SDK

      • Register your integration key after app launch, usually your AppDelegate.swift

        • import QCMP_SDK to use this framework

        • You can use  openConsentForm(_ complianceType: ComplianceType) to open compliance form based on ComplianceType enum: GDPR or CCPA.

        • You also can use request compliance action by ComplianceRequest enum: REQUEST_OPTOUT, REQUEST_DO_NOT_SELL, REQUEST_DELETE_DATA or REQUEST_ACCESS_DATA

        you can see the example of code below:

    • import UIKit
      import QCMP_SDK

      class ViewControllerExample: UIViewController {

      let compliance = Compliance.shared

      @IBAction func openConsentGDPR() {
      compliance.openConsentForm(complianceType: .GDPR)
      }

      @IBAction func openConsentCCPA() {
      compliance.openConsentForm(complianceType: .CCPA)
      }

      @IBAction func requestOptOut() {
      compliance.initComplianceRequest(requestType: .REQUEST_OPTOUT) { [weak self] (result) in
      self?.handleResult(result, "Opt-out data")
      }
      }

      @IBAction func requestDoNotSell() {
      compliance.initComplianceRequest(requestType: .REQUEST_DO_NOT_SELL) { [weak self] (result) in
      self?.handleResult(result, "Do not sell data")
      }
      }

      @IBAction func requestdeleteData() {
      compliance.initComplianceRequest(requestType: .REQUEST_DELETE_DATA) { [weak self] result in
      self?.handleResult(result, "Delete data")
      }
      }

      @IBAction func requestAccessData() {
      compliance.initComplianceRequest(requestType: .REQUEST_ACCESS_DATA) { [weak self] result in
      self?.handleResult(result, "Access data")
      }
      }

      private func handleResult(_ result: Result<Bool, ComplianceError>, _ operartionName: String) {
      switch result {
      case .success(let isSucceeded):
      if isSucceeded {
      self.showAlert(nil, message: "\(operartionName) succeeded!")
      } else {
      self.showAlert("Error", message: "\(operartionName) failed!")
      }
      case .failure(let error):
      self.showAlert("Error", message: error.message)
      }
      }

      private func showAlert(_ title: String?, message: String) {
      let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
      let okAction = UIAlertAction(title: "OK", style: .default, handler: nil)
      alertController.addAction(okAction)
      self.present(alertController, animated: true, completion: nil)
      }
      }
       

INTEGRATING THE MONETISATION SDK - iOS

STEP 1 - Installation using Cocoapods

Add this line in your Podfile:

pod "QDPublisher", :git => 'https://github.com/datastreamx-plc/ios-data-acquisition-sdk.git'

and then install by type pod install in your command line

 

STEP 2 - Setup Integration Key and Start Tracking

Register your integration key after app launch, after that you can setup your event and start tracking location, usually your AppDelegate.swift

import QDPublisher

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

let publisher = QDPublisher.service
let integrationKey: String = "your integration key here"

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
/// setup integration key
publisher.setup(integrationKey)

///setup event. You need implement method from `QDPublisherDelegate`
publisher.delegate = self

///start tracking location. After you call this method, our SDK will automatically tracking event and do the logic for you
publisher.startTrackingLocation()
}}

Implement QDPublisherDelegate - iOS

After setting publisher.delegate = self you need to implement QDPublisherDelegate

extension AppDelegate: QDPublisherDelegate {

/// this controller used to show alert.
func qdPublisherControllreParent() -> UIViewController? {
window?.rootViewController
}

/// you can handle error in this method.
func qdPublisherOnError(error: Error) {
print(error.localizedDescription)
}

}

Enable Background Update

Click your Project

  • Click Capability

  • Choose Background Modes

  • Enable Location updates

    See images below:

  • Screen Shot 2021-07-02 at 15.18.51
 
Screen Shot 2021-07-02 at 15.19.22
    • TRACKING LOCATION - iOS

      For location tracking, you can use this code QDPublisher.service.track(choosedLocation) in your location service, it usually looks like this: 

    • func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
      guard let choosedLocation: CLLocation = locations.first else { return }
      QDPublisher.service.track(choosedLocation)
      }


Ready to add the Consent Management SDK into your app?
Speak to our data consultant to get started