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

  1. In VisualStudio, right-click on the Dependencies folder within your project.

  2. Select Add Project Reference.

  3. Select the .Net Assembly tab.

  4. Click the Browse button.

  5. 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).


  1. Select cmpsdk.dll file.

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

iOS

Android

Android


  1. 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.

  1. For Android only

    1. Navigate to Resources > layout.
    2. Copy each of the XML files in that directory.
    3. Paste them in your project's Resources > layout directory.
    4. 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.


  1. For iOS only

    1. Copy Main.storyboard and paste it in your project.

📘

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.

  1. In VisualStudio, right click the References folder within your project.
  2. Select Add Reference.
  3. Select the .Net Assembly tab.
  4. Click the Browse button.
  5. 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).
  6. Select the cmpsdk.dll file.
  7. 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.

  1. Navigate to the MAUI-With-UI / OneTrust SDK directory in your downloads.
  2. 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.

  1. 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

  1. Download the Unity package from your OneTrust tenant.
  2. In the Unity engine, import a new package and select the OneTrust package from the file explorer.
  3. Import all files.
  4. From here, a demo scene is available with many common use cases.