How-To Tutorials
C#
Permissions
you can integrate the ditto sdk into c# projects to develop for a wide range of platforms for a complete overview of the platforms, transports, and devices the c# sdk supports, see docid\ hov sej 0gyfgzsdkdd0a to install the c# sdk confirm that you meet the minimum requirements ( docid\ jkjoohayi8tiz7v d9af ) prepare your environment for ditto ( docid\ jkjoohayi8tiz7v d9af ) set up your app permissions ( /#setting up permissions ) add ditto to your app ( docid\ jkjoohayi8tiz7v d9af ) prerequisites following are the minimum requirements that must be met before attempting to install ditto https //learn microsoft com/en us/dotnet/standard/net standard?tabs=net standard 2 1#net standard versions https //dotnet microsoft com/en us/download/dotnet/3 0 https //dotnet microsoft com/en us/download/dotnet framework/net40 installing dependencies using either the nuget package manager, net cli, or adding a reference to your csproj xml file install package ditto version 4 3 0 dotnet add package ditto version 4 3 0 \<packagereference include="ditto" version="4 3 0" /> for the official net standard for ditto, see the official nuget reference at packages > https //www nuget org/packages/ditto/ permissions configurations if developing for android or ios targets through frameworks like xamarin forms and multi platform app ui ( maui ), once you've integrated the ditto dependency in your environment, configure your permissions as appropriate xamarin is a microsoft developed framework for building cross platform apps using c# building upon xamarin's foundation, maui offers additional features and various cross‑platform development improvements for more information, see microsoft for the official https //learn microsoft com/en us/xamarin/ setting up permissions due to both android and ios limiting access to some device functionality for end‑user control and privacy by default, for ditto to function optimally and use all the network transports — bluetooth low energy (le), local area network, and so on — configure your app to automatically request all necessary permissions from end users at runtime by doing the following for more information on permissions requirements for android os, see the official android documentation > https //developer android com/develop/connectivity/bluetooth/bt permissions and https //developer android com/develop/connectivity/wifi/wifi permissions add the following permissions to your project's androidmanifest xml file the tools\ targetapi attribute ensures you avoid errors in older os versions that do not recognize the permission the android\ maxsdkversion attribute ensures you avoid asking for more permissions than ditto needs by preventing permission requests on devices running a newer os version to opt out of this behavior, see step 2 androidmanifest xml \<manifest xmlns\ tools="http //schemas android com/tools" xmlns\ android="http //schemas android com/apk/res/android"> \<uses permission android\ name="android permission bluetooth" android\ maxsdkversion="30" /> \<uses permission android\ name="android permission bluetooth admin" android\ maxsdkversion="30" /> \<uses permission android\ name="android permission bluetooth advertise" tools\ targetapi="s" /> \<uses permission android\ name="android permission bluetooth connect" tools\ targetapi="s" /> \<uses permission android\ name="android permission bluetooth scan" android\ usespermissionflags="neverforlocation" tools\ targetapi="s" /> \<uses permission android\ name="android permission access fine location" android\ maxsdkversion="32" /> \<uses permission android\ name="android permission access coarse location" android\ maxsdkversion="30" /> \<uses permission android\ name="android permission internet" /> \<uses permission android\ name="android permission access wifi state" /> \<uses permission android\ name="android permission access network state" /> \<uses permission android\ name="android permission change network state" /> \<uses permission android\ name="android permission change wifi multicast state" /> \<uses permission android\ name="android permission change wifi state" /> \<uses permission android\ name="android permission nearby wifi devices" android\ usespermissionflags="neverforlocation" tools\ targetapi="tiramisu" /> if you want to request permissions on all os versions, regardless of api ( tools\ targetapi ) and sdk levels ( tools\ targetapi ), add the following to override the location permission option androidmanifest xml location permission override option \<uses permission android\ name="android permission access fine location" tools\ remove="android\ maxsdkversion" /> \<uses permission android\ name="android permission access coarse location" tools\ remove="android\ maxsdkversion" /> features related to runtime permissions management for android is planned for future release from your info plist file, add the following key value pairs, and then, if applicable, modify each string assigned to value once implemented, the following string values display as a prompt to your end users explaining why the app requires certain permissions if your end users prefer a language other than english, replace the string values with their language equivalents or use localized strings \<key>nsbluetoothalwaysusagedescription\</key> \<string>uses bluetooth to connect and sync with nearby devices\</string> \<key>nslocalnetworkusagedescription\</key> \<string>uses wifi to connect and sync with nearby devices\</string> \<key>nsbonjourservices\</key> \<array> \<string> http alt tcp \</string> \</array> ensure uninterrupted syncing, by enabling bluetooth background modes in your info plist file once enabled, you ensure your app continuously runs in the background, even when the end user's device is locked \<key>uibackgroundmodes\</key> \<array> \<string>bluetooth central\</string> \<string>bluetooth peripheral\</string> \</array> integrating ditto integrate ditto with your app for instructions on how to obtain your access credentials, see docid\ icofpongvbykvggqjktwx for an introduction to authentication in ditto, see ditto basics > docid 3vo4onmgepp4s9iam0hbz try { dittologger setminimumloglevel(dittologlevel debug); var ditto = new ditto(dittoidentity onlineplayground("replace me with your app id", "replace me with your playground token", true), path); ditto startsync(); } catch (dittoexception ex) { console writeline($"ditto error {ex message}"); } var insertargs = new dictionary\<string, object>(); insertargs add("newcar", new { id = "123", color = "blue" }) await ditto store executeasync( "insert into cars documents (\ newcar)", insertargs);