Add SDK to App
Overview
Before you begin
Prior to implementing the MAUI / .Net SDK into your MAUI / .Net application, you first need to decide what kind of implementation path you need:
- .Net Native iOS and .Net Native Android
- MAUI
.Net Native iOS and .Net Native Android steps
-
In VisualStudio, right-click on the Dependencies folder within your project.
-
Select Add Project Reference.
-
Select the .Net Assembly tab.
-
Click the Browse button.
-
Locate the cmpsdk.dll file within the OneTrust_CMP_DotNet7_DLL folder (for .Net7 project) or the OneTrust_CMP_DotNet8_DLL folder (for .Net8 project).

- Select cmpsdk.dll file.

- Click the OK button. You should see cmpsdk in your Assemblies section.

iOS

Android
- For iOS, copy the OneTrustSDK folder from the DotNet-Native-With-UI/otsdk.dotnet.ios directory and paste it into your .Net iOS project. For Android, do the same with otsdk.dotnet.android.

-
For Android only
- Navigate to Resources > layout.
- Copy each of the XML files in that directory.
- Paste them in your project's Resources > layout directory.
- Select one of the files, then navigate to the Build action dropdown on the Properties tab and select AndroidResource.
You will need to repeat this step for each file in the layout directory.


We recommend using the DotNet-Native-With-UI sample project as a reference on how to communicate with the cmpsdk.dll.
MAUI steps
First, you need to add the OneTrust SDK's dll file to your existing application.
- In VisualStudio, right click the References folder within your project.
- Select Add Reference.
- Select the .Net Assembly tab.
- Click the Browse button.
- Locate the cmpsdk.dll file within the OneTrust_CMP_DotNet7_DLL folder (for .Net7 project) or the OneTrust_CMP_DotNet8_DLL folder (for .Net8 project).
- Select the cmpsdk.dll file.
- Click the OK button.
Since you plan to use the OneTrust UI, you will need to also copy the UI files into your MAUI shared project.
- Navigate to the MAUI-With-UI / OneTrust SDK directory in your downloads.
- Copy and paste that folder into your existing MAUI project.
There are additional dependencies to inject into your existing application. For MAUI, it is necessary to include these files in your project to avoid build errors.
- For iOS, locate the MAUI-With-UI / Platforms / iOS / Handlers folder and copy all files within into your project.
For OneTrust sample app, the shared project name is MAUI-With-UI. Your project name will be different.
We recommend using the MAUI-With-UI sample project as a reference on how to communicate with the cmpsdk.dll. Additionally, we suggest using the MainPage.xaml file to launch the OneTrust UI.
Add SDK to App for Unity
- Download the Unity package from your OneTrust tenant.
- In the Unity engine, import a new package and select the OneTrust package from the file explorer.
- Import all files.
- From here, a demo scene is available with many common use cases.
Updated 14 days ago