This document provides instructions for customizing the UI colors and fonts used by the InMobi CMP in mobile applications built on Android, iOS, and Unity. UI customization enables developers to match the consent UI with the host app’s look and feel by modifying text styles, font settings, and color schemes.
Customization for Android apps can be done both from the Themes tab on the InMobi CMP portal and in the code of the SDK. For steps to customise color and font through the InMobi CMP portal, see Create App Theme.
While both color and font customisation can be done through code, InMobi CMP gives priority to customisations enabled through the portal. First, we will consider the customisations from the portal; if there are none, we will consider the customisations made through code. In case there are no changes made through code, we will apply the default colors and fonts.
This section details how to utilize various configuration options for text styles and colors on Android via code.
You can control light/dark mode by using ThemeMode while calling startChoice method. It can take three values:
You can pass the ChoiceColor model to set themes in light and dark mode. If only one model is passed in AUTO themeMode, InMobi CMP SDK will use the same model for both light and dark mode. To create your theme, follow the steps:
ChoiceColor model and set all the necessary colors for that model.ChoiceStyle object through the builder and set the appropriate ChoiceColor object for light and dark mode resources.ChoiceStyle object in the startChoice method.
fun initChoice() {
ChoiceCmp.startChoice(
app = application,
packageId = packageId,
pCode = "your pcode",
callback= choiceCmpCallback,
choiceStyle = ChoiceStyle.Builder().setThemeMode(ThemeMode.AUTO).
setLightModeColors(getColors()).
setDarkModeColors(getColors()).build()
)
}
private fun getColors(): ChoiceColor {
val choiceColor = ChoiceColor()
choiceColor.dividerColor = getColorInt(R.color.dividerColor)
choiceColor.tabBackgroundColor = getColorInt(R.color.tabBackgroundColor)
choiceColor.tabTextColor = getColorInt(R.color.tabTextColor)
choiceColor.searchBarBackgroundColor = getColorInt(R.color.searchBarBackgroundColor)
choiceColor.searchBarForegroundColor = getColorInt(R.color.searchBarForegroundColor)
choiceColor.toggleActiveColor = getColorInt(R.color.toggleActiveColor)
choiceColor.toggleInactiveColor = getColorInt(R.color.toggleInactiveColor)
choiceColor.globalBackgroundColor = getColorInt(R.color.globalBackgroundColor)
choiceColor.titleTextColor = getColorInt(R.color.titleTextColor)
choiceColor.bodyTextColor = getColorInt(R.color.bodyTextColor)
choiceColor.menuTextColor = getColorInt(R.color.menuTextColor)
choiceColor.linkTextColor = Color.parseColor(R.color.linkTextColor)
choiceColor.buttonTextColor = getColorInt(R.color.buttonTextColor)
choiceColor.buttonBackgroundColor = getColorInt(R.color.buttonBackgroundColor)
choiceColor.buttonDisabledTextColor = getColorInt(R.color.buttonDisabledTextColor)
choiceColor.buttonDisabledBackgroundColor = getColorInt(R.color.buttonDisabledBackgroundColor)
return choiceColor
}
private fun getColorInt(colorRes: Int): Int {
return ContextCompat.getColor(this, colorRes)
}
If you wish to customise the fonts used in the Choice CMP, follow the instructions below:
startChoice method. The table below provides details on the two types of supported fonts and their corresponding property names in the ChoiceStyle class in the CMP:| Property name | Description |
|---|---|
regularFont |
Name of the font used for the CMP |
boldFont |
Name of the bold font used for the CMP |
Below is an example demonstrating how the startChoice call will appear once you've integrated custom fonts:
ChoiceCmp.startChoice(
app = application,
packageId = packageId,
pCode = "your pcode",
callback= choiceCmpCallback,
choiceStyle = ChoiceStyle.Builder().setThemeMode(ThemeMode.AUTO).
setLightModeColors(getColors()).
setDarkModeColors(getColors()).
setRegularFont(R.font.open_sans_regular).
setBoldFont(R.font.luckiest_guy).build()
)
Customisation for iOS apps can be done both from the Themes tab on the InMobi CMP portal and in the code of the SDK. For steps to customise color and font through the InMobi CMP portal, see Create App Theme.
While both color and font customisation can be done through code, InMobi CMP gives priority to customisations enabled through the portal. First, we will consider the customisations from the portal; if there are none, we will consider the customisations made through code. In case there are no changes made through code, we will apply the default colors and fonts.
This section details how to utilize various configuration options for text styles and colors on iOS via code.
You can control light/dark mode by using preferredThemeMode while calling ChoiceStyle method. It can take three values:
To customize the UI text styles and colors according to your application, follow these steps:
lightModeColors and darkModeColors respectively In the ChoiceStyle API.Example:
// Start ChoiceCMP
let style = ChoiceStyle(preferredThemeMode: .auto, lightModeColors: defaultColors, darkModeColors: defaultColors)
ChoiceCmp.shared.startChoice(pcode: "<YOUR-PCODE", delegate: self, gbcDelegate: self, style: style)
ChoiceStyle *style = [[ChoiceStyle alloc] initWithPreferredThemeMode:CMPUserInterfaceStyleAuto lightThemeStyleSheet:@"LightStyleSheet" darkThemeStyleSheet:@"DarkStyleSheet"];
[ChoiceCmp.shared startChoiceWithPcode:@"< YOUR PCODE >" delegate:self ccpaDelegate:self shouldDisplayIDFA:true style:style];
The following components can be configured:
| Property name | Description |
|---|---|
| dividerColor | Page divider color |
| tabBackgroundColor | Tab background color (for example, the vendor tabs) |
| tabForegroundColor | Tab foreground color (for example, the vendor tabs) |
| searchBarBackgroundColor | Search field background color |
| searchBarForegroundColor | Search field foreground color |
| infoButtonForegroundColor | Information (i) button foreground color |
| infoScreenBackgroundColor | Information screen background color |
| infoScreenForegroundColor | Information screen foreground color |
| toggleActiveColor | Toggle button active color |
| toggleInactiveColor | Toggle button in-active color |
| globalTextColor | Main (global) text color |
| globalBackgroundColor | Main (or global) background color |
| titleTextColor | Title text color |
| bodyTextColor | Body text color |
| listTextColor | Color of the text in the lists (like vendor list) |
| tabTextColor | Tab text color (for example the vendor tabs) |
| menuTextColor | Menu text color (example: ???) |
| linkTextColor | Link text color (hyperlinks and links between the different pages) |
| buttonTextColorButton text color | Button text color |
| buttonDisabledTextColor | Button text color in disabled state |
| buttonBackgroundColor | Button background color |
| buttonDisabledBackgroundColor | Button background color in disabled state |
There is an option to customise the fonts utilized in the InMobi CMP. By default, the OS default font is applied. To configure custom fonts, the host application must support their integration. For more information, see Adding a Custom Font to Your App
To find the correct names for utilizing custom fonts in your source code, please refer to the dedicated section: Use Your Custom Font in Source Code.
You can leverage boldFont parameter provided in ChoiceStyle to set the font.
let boldFont = ChoiceFont()
boldFont.fontName = "<FONT NAME>"
let style = ChoiceStyle(preferredThemeMode: .auto, lightModeColors: defaultColors, darkModeColors: defaultColors, boldFont: boldFont)
ChoiceCmp.shared.startChoice(pcode: "YOUR PCODE", delegate: self, gbcDelegate: self, style: style)
//
// AppDelegate.swift
// Example
//
// Copyright © 2024 InMobi. All rights reserved.
//
import UIKit
import InMobiCMP
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, ChoiceCmpDelegate, CCPADelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
startChoice()
return true
}
func startChoice() {
// Start ChoiceCMP
let boldFont = ChoiceFont()
boldFont.fontName = "FONT NAME"
let style = ChoiceStyle(preferredThemeMode: .auto, lightModeColors: defaultColors, darkModeColors: defaultColors, boldFont: boldFont)
ChoiceCmp.shared.startChoice(pcode: "YOUR-PCODE", delegate: self, gbcDelegate: self, style: style)
}
var defaultColors : ChoiceColor {
let choiceColor = ChoiceColor()
choiceColor.dividerColor = "#CCBBFF"
choiceColor.tabBackgroundColor = "#BAABEA"
choiceColor.tabForegroundColor = "#8844FF"
choiceColor.searchBarBackgroundColor = "#CCBBFF"
choiceColor.searchBarForegroundColor = "#BAABEA"
choiceColor.infoButtonForegroundColor = "#8844FF"
choiceColor.infoScreenBackgroundColor = "#CCBBFF"
choiceColor.infoScreenForegroundColor = "#5533BB"
choiceColor.toggleActiveColor = "#8844FF"
choiceColor.toggleInactiveColor = "#CCBBFF"
choiceColor.globalTextColor = "#5533BB"
choiceColor.globalBackgroundColor = "#EEDDFF"
choiceColor.titleTextColor = "#5533BB"
choiceColor.bodyTextColor = "#5533BB"
choiceColor.listTextColor = "#5533BB"
choiceColor.tabTextColor = "#5533BB"
choiceColor.menuTextColor = "#5533BB"
choiceColor.linkTextColor = "#8844FF"
choiceColor.buttonTextColor = "#BAABEA"
choiceColor.buttonDisabledTextColor = "#8844FF"
choiceColor.buttonBackgroundColor = "#8844FF"
choiceColor.buttonDisabledBackgroundColor = "#CCBBFF"
return choiceColor
}
}
Customization for Unity apps is not done through the Themes tab and must be done directly in the code of the SDK. We recommend following these instructions at a later stage, once you have downloaded our Unity plugin.
This section details how to utilize various configuration options for text styles and colors on Unity.
You can control light/dark mode by using ThemeMode while calling startChoice method. It can take three values:
You can pass the ChoiceColor model for setting themes in light and dark mode. If only one model is passed in AUTO themeMode, InMobi CMP SDK will use the same model for both light and dark mode. To create your theme follow the steps:
ChoiceColor model and set all the necessary colors to that model.ChoiceStyle object and set the appropriate ChoiceColor object for light and dark mode resources.ChoiceStyle object in the startChoice method.
public void StartChoice()
{
ChoiceCMP.StartChoice(pCode, getChoiceStyle(), true);
}
private ChoiceStyle getChoiceStyle() {
ChoiceStyle choiceStyle = new ChoiceStyle();
choiceStyle.themeMode = ThemeMode.AUTO;
choiceStyle.lightModeColors = getColors();
choiceStyle.darkModeColors = getColors();
return choiceStyle;
}
private ChoiceColor getColors() {
ChoiceColor choiceColor = new ChoiceColor();
choiceColor.dividerColor = "#CCBBFF";
choiceColor.tabBackgroundColor = "#BAABEA";
choiceColor.tabForegroundColor = "#8844FF";
choiceColor.searchBarBackgroundColor = "#CCBBFF";
choiceColor.searchBarForegroundColor = "#BAABEA";
choiceColor.infoButtonForegroundColor = "#8844FF";
choiceColor.infoScreenBackgroundColor = "#CCBBFF";
choiceColor.infoScreenForegroundColor = "#5533BB";
choiceColor.toggleActiveColor = "#8844FF";
choiceColor.toggleInactiveColor = "#CCBBFF";
choiceColor.globalTextColor = "#5533BB";
choiceColor.globalBackgroundColor = "#EEDDFF";
choiceColor.titleTextColor = "#5533BB";
choiceColor.bodyTextColor = "#5533BB";
choiceColor.listTextColor = "#5533BB";
choiceColor.tabTextColor = "#5533BB";
choiceColor.menuTextColor = "#5533BB";
choiceColor.linkTextColor = "#8844FF";
choiceColor.buttonTextColor = "#BAABEA";
choiceColor.buttonDisabledTextColor = "#8844FF";
choiceColor.buttonBackgroundColor = "#8844FF";
choiceColor.buttonDisabledBackgroundColor = "#CCBBFF";
return choiceColor;
}
The following components can be configured:
| Property name | Description |
|---|---|
| dividerColor |
Color of the dividers between list items and the border color of the description items |
| tabBackgroundColor | Tab background color (for examples the vendor tabs) |
| tabForegroundColor | Tab foreground color (for examples the vendor tabs) |
| searchBarBackgroundColor | Search field background color |
| searchBarForegroundColor | Search field foreground color |
| toggleActiveColor | Toggle button active color |
| toggleInactiveColor | Toggle button in-active color |
| globalBackgroundColor | Main (or global) background color |
| titleTextColor | Title text color |
| bodyTextColor | Body text color |
| tabTextColor |
Color of the items in the toolbar, such as the title, back button, and menu button |
| menuTextColor |
Text color of the menu items (example: menu items in consent and legitimate interest tabs) |
| linkTextColor |
Link text color (hyperlinks and links between the different pages) |
| buttonTextColorButton text color | Button text color |
| buttonDisabledTextColor | Button text color in disabled state |
| buttonBackgroundColor | Button background color |
| buttonDisabledBackgroundColor | Button background color in disabled state |
| Property name | Description |
|---|---|
| dividerColor | Page divider color |
| tabBackgroundColor | Tab background color (for example, the vendor tabs) |
| tabForegroundColor | Tab foreground color (for example, the vendor tabs) |
| searchBarBackgroundColor | Search field background color |
| searchBarForegroundColor | Search field foreground color |
| infoButtonForegroundColor | Information (i) button foreground color |
| infoScreenBackgroundColor | Information screen background color |
| infoScreenForegroundColor | Information screen foreground color |
| toggleActiveColor | Toggle button active color |
| toggleInactiveColor | Toggle button in-active color |
| globalTextColor | Main (global) text color |
| globalBackgroundColor | Main (or global) background color |
| titleTextColor | Title text color |
| bodyTextColor | Body text color |
| listTextColor | Color of the text in the lists (like vendor list) |
| tabTextColor | Tab text color (for example the vendor tabs) |
| menuTextColor | Menu text color (example: ???) |
| linkTextColor | Link text color (hyperlinks and links between the different pages) |
| buttonTextColorButton text color | Button text color |
| buttonDisabledTextColor | Button text color in disabled state |
| buttonBackgroundColor | Button background color |
| buttonDisabledBackgroundColor | Button background color in disabled state |
If you wish to customize the fonts used in the Choice CMP, follow the instructions below:
ChoiceStyle object as a param.
ChoiceStyle choiceStyle = new ChoiceStyle();
choiceStyle.themeMode = ThemeMode.AUTO;
choiceStyle.lightModeColors = getColors();
choiceStyle.darkModeColors = getColors();
choiceStyle.boldFont = "Luckiest Guy";
choiceStyle.regularFont = "Luckiest Guy";
return choiceStyle;
To attach the font files to the project, follow the steps below:
If you are facing any issue like "You have not accepted the license agreements of the following SDK components”, then follow the steps below:
To avoid any confusions, keep the font filename same as the font itself for e.g if your font is CustomFont-Light, then keep the filename as CustomFont-Light.ttf
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.