Follow the instructions to integrate Unity.
You must use the Unity version 2020.1.10f1 or above for InMobi Unity Plugin to ensure a smoother experience.
Import the InMobi SDK header and initialize it.
public void InitializeInMobiAds()
{
UpdateLogs("initializeInMobiAds ");
InMobiPlugin inmobiPlugin = new InMobiPlugin();
inmobiPlugin.OnInitializationCompleted += this.HandleInitializationStatus;
Dictionary<string, object=""> consentObject = new Dictionary<string, object="">();
consentObject.Add(InMobiPlugin.IM_GDPR_CONSENT_AVAILABLE, true);
consentObject.Add(InMobiPlugin.IM_GDPR_CONSENT_IAB, "IAB_STRING");
inmobiPlugin.Init("<inmobi account="" id="">", consentObject);
inmobiPlugin.SetLogLevel("Debug");
inmobiPlugin.SetAge(23);
}
public void HandleInitializationStatus (object sender, SdkInitializationStatusArgs args) {
UpdateLogs("SDK Initialization status code : " + args.status.Code + " and reason : " + args.status.Reason);
} </inmobi></string,></string,>
Create a user data model as follows:
InMobiUserDataTypes emailIdData = new InMobiUserDataTypes();
emailIdData.Md5 = CreateMD5(emailID);
emailIdData.Sha1 = CreateSHA1(emailID);
emailIdData.Sha256 = CreateSHA256(emailID);
InMobiUserDataTypes phoneNumberData = new InMobiUserDataTypes();
phoneNumberData.Md5 = CreateMD5(phoneNumber);
phoneNumberData.Sha1 = CreateSHA1(phoneNumber);
phoneNumberData.Sha256 = CreateSHA256(phoneNumber);
InMobiUserDataModel userDataModel = new InMobiUserDataModel();
userDataModel.EmailID = emailIdData;
userDataModel.PhoneNumber = phoneNumberData;
// Pass this data model to fetch the API.
InMobiUnifiedIdService.Push(userDataModel);
Use this API to fetch the UnifFI IDs.
InMobiUnifiedIdService.FetchUnifiedIds();
Callback:
public void onFetchCompleted(object sender, OnFetchCompletedEventArgs e)
{
UnityMainThreadHelper.GetInstance().PostTask(() => {
Logger.getInstance().log("onFetchCompleted" + e.unifiedIds + " " + e.error, logField);
});
}
Sample Code
public InputField logField;
public void onFetchCompleted(object sender, OnFetchCompletedEventArgs e)
{
UnityMainThreadHelper.GetInstance().PostTask(() => {
Logger.getInstance().log("onFetchCompleted" + e.unifiedIds + " " + e.error, logField);
});
}
private void Start()
{
InMobiUnifiedIdService.OnFetchCompleted += onFetchCompleted;
}
public void onFetch()
{
Logger.getInstance().log("Fetch Called", logField);
InMobiUnifiedIdService.FetchUnifiedIds();
}
Call the following reset API to clear all the user-related data and Ids stored in the SDK.
InMobiUnifiedIdService.Reset();
Use the following function to pass the UIDs (Universal IDs) obtained by having direct partnerships with different ID partners (e.g., liveramp, id5, and so on.), upstream to demand partners, or to other ad exchanges.
InMobiSdk.setPublisherProvidedUnifiedID(Dictionary unifiedIds);
Sample Code
InMobiPlugin inMobiPlugin = new InMobiPlugin();
Dictionary<string, object=""> unifIds = new Dictionary<string, object="">();
unifIds.Add("key0", "value0");
unifIds.Add("nestedJson", level1);
inMobiPlugin.SetPublisherProvidedUnifiedId(unifIds); </string,></string,>
By installing this SDK update, you agree that your Children Privacy Compliance setting remains accurate or that you will update that setting, whenever there is a change in your app's audience. You may update the app's Children Privacy Compliance settings at https://publisher.inmobi.com/my-inventory/app-and-placements.