C#
You can integrate the Ditto SDK into C# projects to develop for platforms, including mobile apps for iOS and Android, desktop apps, Linux-enabled server systems, and more.
To install the C# SDK:
Confirm that you meet the minimum requirements. (Prerequisites)
Install the Ditto SDK. (Installing Dependencies)
Set up your app permissions. (Configuring Permissions)
Add Ditto to your app. (Initializing Ditto)
Prerequisites
Following are the minimum requirements that must be met before attempting to install Ditto:
Installing Dependencies
Using either a compatible package manager, the .NET CLI, or by adding a reference to the package: CSProj.xml
file, install the Ditto SDK by doing any of the following:
If using a package manager other than NuGet, the official package manager for .NET, the command syntax to install Ditto may differ from the following snippet. For more information, see the official Nuget documentation > Ditto .NET Standard.
For the official .NET standard for Ditto, see the official NuGet reference at Packages > Ditto.
Configuring Permissions
To set up your environment for your target platform:
For apps targeting iOS; for example, MAUI, once you’ve added the Ditto package dependency, configure permissions and ensure your app continues syncing while running in the background, including when the end-user device is locked, by enabling background modes.
Open the Info.Plist
file for your project.
Add the following key-value pairs, and then, if desired, modify each string value:
Enable Bluetooth Background Modes:
For apps targeting iOS; for example, MAUI, once you’ve added the Ditto package dependency, configure permissions and ensure your app continues syncing while running in the background, including when the end-user device is locked, by enabling background modes.
Open the Info.Plist
file for your project.
Add the following key-value pairs, and then, if desired, modify each string value:
Enable Bluetooth Background Modes:
For apps targeting Android, once you’ve added the Ditto package dependency, configure the necessary permissions:
Open the AndroidManifest.xml
file typically located in the src/main/
directory of your project.
Add the necessary permissions to ensure your app has the permissions required by Ditto:
For instructions on how to modify the following configuration for permissions requests; for example, prevent your app from requesting unnecessary permissions on newer OS versions or ensure compatibility with both older and newer OS versions, see Customizing Permissions.
Customizing Permissions
To modify the behavior of permission requests for the Android target:
Features related to runtime permissions management for Android is planned for future release.
Add the following namespace attribute to the root <manifest>
tag of your AndroidManifest.xml
file:
To request permissions on all OS versions of Android:
To limit permissions request, use the following attributes as desired:
tools:targetApi
The tools:targetApi
attribute allows you to specify that a permission should only be requested on devices running a specified Android API level or higher.
By limiting permissions requests, you prevent errors that result from asking permissions on devices running older OS versions of Android.
android:maxSdkVersion
With the android:maxSdkVersion
attribute, you can customize to only initiate a permission request on devices running a specified Android API level or lower.
Setting to a specified API level or lower helps avoids unnecessary permissions requests on devices running newer OS versions of Android.
Initializing Ditto
Once you’ve installed the Ditto SDK, set the debug level you want Ditto to log messages for, create a new Ditto identity, and set up Ditto exception handling for data sync operations:
Next Steps
Learn how to build a task list app built on .NET Maui and integrated with Ditto by going to the MAUI Task App how-to tutorial.