UnifID 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)" 
} 

On This Page

Last Updated on: 07 Apr, 2021