Sample Integration

To configure UnifID for Android and iOS devices, follow this sample integration.

iOS Setup

Initialization

1. Import the InMobi SDK header and initialize it:

IMSdk.initWithAccountID("accountID", consentDictionary: [IM_GDPR_CONSENT_AVAILABLE: 
"true", IM_GDPR_CONSENT_IAB: "<<consent in IAB format>>" ]) { (error) in
            if let error = error {
                print(error.localizedDescription)
            } 
}

2. Create a user data model as follows:

let phoneNumber = IMUserDataTypes(md5: "2wse3e", sha1: "5tfg7yh", sha256: "6tghjk")
let emailId = IMUserDataTypes(md5: "ujhjk99", sha1: "9ujkhgtyf", sha256: "jhjyure4")

let userDataModel = IMUserDataModel(phoneNumber: phoneNumber, emailId: emailId, extra: nil)

 3. Pass this data model to fetch the API:

IMUnifiedIdService.push(data: userDataModel) 

4. Call this API to fetch the UnifIDs.

IMUnifiedIdService.fetchUnifiedIds(delegate: self)

Callbacks

Implement the following delegates to receive the callbacks.

class ViewController: IMUnifiedIdInterface {
    onFetchCompleted(response: Dictionary?, error: Error?) {
    }
}

Reset

Call this reset API to clear all the user-related data and IDs stored in the SDK:

IMUnifiedIdService.reset()

Publisher provided Unified Ids (Optional)

If you have an ID from a Vendor, you can use it in the following SDK. If there is an overlap, the system prioritizes the InMobi procured Unified IDs.

IMSdk.setPublisherProvidedUnifiedID(unifiedIds : Dictionary?);

JSONObject structure:

{
    "id5" : "json(blob)",
    "live Ramp": "json(blob)"
}

Android Setup

Initialization

1. Import the InMobi SDK header and initialize it.

InMobiSdk.init(this, "Insert InMobi Account ID here", consentObject, new SdkInitializationListener() {
    @Override
    public void onInitializationComplete(@Nullable Error error) {
        if (null != error) {
            Log.e(TAG, "InMobi Init failed -" + error.getMessage());
        } else {
            Log.d(TAG, "InMobi Init Successful");
        }
    }
});

2. Create a user data model as follows:

InMobiUserDataTypes phoneNumber = new
InMobiUserDataTypes.Builder().md5("2wse3e").sha1("5tfg7yh").sha256("6tghjk").build();

InMobiUserDataTypes emailId = new I
nMobiUserDataTypes.Builder().md5("ujhjk99").sha1("9ujkhgtyf").sha256("jhjyure4").build();

HashMap<String, String> extras = new HashMap<>();
extras.put("appSpecificUniqueId", "XXXXXXXX");

InMobiUserDataModel userDataModel = new
InMobiUserDataModel.Builder().phoneNumber(phoneNumber).emailId(emailId).extras(extras).build(); 

3. Pass this data model to fetch the API.

InMobiUnifiedIdService.push(userDataModel)

4. Use this API to fetch the UnifIDs.

InMobiUnifiedIdService.fetchUnifiedIDs(this)

Callbacks

Implement the following delegates to receive the callbacks.

class MyActivity implements InMobiUnifiedIDInterface {
   @Override
        public void onFetchCompleted(JSONObject response, Error error) {
        }
} 

Reset

Call this reset API to clear all the user-related data and Ids stored in the SDK.

InMobiUnifiedIdService.reset()

Publisher provided Unified Ids (Optional)

If you have an ID from a Vendor, you can use it in the following SDK. If there is an overlap, the system prioritizes the InMobi procured Unified IDs.

InMobiSdk.setPublisherProvidedUnifiedID(JSONObject unifiedIds);

JSONObject structure:

{ 
    "id5" : "json(blob)", 
    "live Ramp": "json(blob)" 
} 

Recommended Usage

InMobi’s Unifi APIs expects hashed e-mail or telephone numbers to generate the identity envelope. To enhance matching, ensure to

  • Remove whitespace, blank spaces, tabs, and other characters from the plain language e-mail id.
  • Convert all the uppercase characters to lowercase.
  • Validate the email id against a regular expression.

Example: test@example.com, test@gmail.com.

Note

For email ids with @gmail.com:

  • Remove ‘.’ (ASCII code 46) from the username of the e-mail address. jane.doe@gmail.com normalizes to janedoe@gmail.com.
  • Remove ‘+’ (ASCII code 43) and all subsequent characters from the username of the e-mail address. janedoe+home@gmail.com normalizes to janedoe@gmail.com.

Testing Instructions

The request to the Unifid ID endpoint will not be made during the first session. From the next application start/session, the request is sent to the Unifid ID endpoint with the identity payload. Unifi ID endpoint:

Testing using Fetch( ) API

The quickest way to test the Unifid ID integration is to use InMobi Unifid Fetch API and implement its callback.

fetchUnifiedIds(delegate: UnifiedIdInterface):

The callback will have identities details in JSON Object/dictionary.

Sample Response

{ 
"ufids": [{ 
"src": "Liveramp", 
"envelope": "ApLA0JHjsUo3sCSO6NeT6i87P6eVAYuskookH7tFd-bknddGiOAeyXR9nUK8io0VaR5f32DDHMIEFYZfmo7KenUacv_hhZwxFA", 
"expiry": 1619170252591 
}, { 
"src": "ID5", 
"signature": "ID5_AUaTt3TDEeoZCyJsqeC1fIL9E-Jl675HrwbJ-0--n47mq_QPpFh6uK79MIGGbbejZGlOawA48-4A3o7fTBRpRNs", 
"envelope": "eyJjcmVhdGVkX2F0IjoiMjAyMS0wNC0yMlQwOTozMDo1Mi41MThaIiwiaWQ1X2NvbnNlbnQiOiJ0cnVlIiwic2lnbmF0dXJlIjoiSUQ1X0FVYVR0M1RERWVvWkN5SnNxZUMxZklMOUUtSmw2NzVIcndiSi0wLS1uNDdtcV9RUHBGaDZ1Szc5TUlHR2JiZWpaR2xPYXdBNDgtNEEzbzdmVEJScFJOcyIsIm9yaWdpbmFsX3VpZCI6IklENS1aSE1PajBUWUpaM0toX2xpLVcwTXVkS2hTXzFzVTlJeUtrVVJJV2tUN3chIiwidW5pdmVyc2FsX3VpZCI6IklENS1aSE1PajBUWUpaM0toX2xpLVcwTXVkS2hTXzFzVTlJeUtrVVJJV2tUN3chIiwibGlua190eXBlIjoiMCJ9", 
"expiry": 1619170252591 
}, { 
"src": "Britepool", 
"envelope": "eyJjb25maWRlbmNlIjowLjksInByaW1hcnlCUElEIjoiYmI5NjNjNmEtMDQ3Yy00NzZjLWFhZWYtMTNhNDUxYTI3YWMzIn0=", 
"expiry": 1619170252591 
}] 
}

Testing using Charles tool

Charles is an HTTP proxy / HTTP monitor / Reverse Proxy that enables a developer to view all of the HTTP and SSL / HTTPS traffic between their machine and the Internet. Follow Charles' instructions to install an SSL certificate on the Android emulator or mobile device.

Please refer to the below documentation on how to set up the Charles tool:

Configuring SSL Proxy on Mobile

Charles Official Website

Note

The logs below are gathered after the first session or launch of the application and must enable SSL proxy.

Launch your app and look for HTTP requests for unifiedID endpoint in the Charles log. Please refer to the below snapshot. If the integration is correct then, in the response body you’ll have the identity envelope with an expiry date.

Unified Endpoint: https://unif-id.ssp.inmobi.com/fetch

Make an ad request to InMobi and check for the URL: https://ads.inmobi.com. In the response body, check for the header ‘ufid’.  If integration is successful, you’ll see the same identity.

On This Page

Last Updated on: 06 Sep, 2021