Public Preview - This version is in public preview and subject to changes. For production use, please use SDK v4.
1
Confirm that you meet the minimum requirements. (Prerequisites)
2
Install the Ditto SDK. (Installing Dependencies)
3
Set up your app permissions. (Configuring Permissions)
4
Add Ditto to your app. (Initializing Ditto)
5
(Optional) Declare a foreground service (Android only). (Declaring a Foreground Service)
Prerequisites
Following are the minimum requirements that must be met before attempting to install Ditto:Installing Dependencies
To use the Ditto SDK in your project, you’ll need to install the appropriate NuGet package.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
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.
1
Open the
Info.Plist
file for your project.2
Add the following key-value pairs, and then, if desired, modify each string value:
XML
3
Enable Bluetooth Background Modes:
XML
Requesting Permissions at Runtime
In addition to being declared, some permissions need to be requested from the user at runtime. To ensure your app has the required permissions for sync, use theDittoSyncPermissions
helper class from the Ditto SDK.
This helper class simplifies the process of requesting end-user permissions at runtime with a single method call for all necessary permissions.
Ensure StartSync()
is invoked after permissions have been requested.
C#
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:C#
Declaring a Foreground Service (Android Only)
A foreground service allows your app to continue syncing data with Ditto while running in the background. A foreground service is not required to use Ditto, but without it your app will stop syncing whenever it is in the background. To declare the foreground service, add the following to yourAndroidManifest.xml
:
small_app_icon
drawable must be monochrome white.
The foreground service will be automatically started and stopped on startSync()
and stopSync()
, respectively.