Knowledge Base
FAQs
this article provides expert answers to frequently asked questions (faqs) for the following ditto topics /#general sdk /#battery /#performance /#bluetooth /#databasesync /#connection /#security /#wi fi /#api documentation general sdk which identity should i use to initialize ditto? use online playground for development and online with authentication for production (see docid\ d0b4xrfn45yem15qcycob ) can i use ditto with two separate app ids in the same mobile app? yes use a separate persistencedirectory how do ditto enabled apps sync without internet connectivity? there are 3 ways for ditto enabled apps to sync without connectivity wifi access point (lan) wifi access point, also known as lan, is when devices discover and sync with each other over the same local network typically, this means you have a wireless access point where your devices are all connected to even if the internet or modem fails, devices will still be able to synchronize this is completely cross platform wifi direct and apple wireless direct ios and android devices are able to create peer to peer wifi connections with each other however these are not cross platform meaning that, ios devices are only able to connect to other ios devices via apple wireless direct android devices are able to make p2p wifi direct connections with each other bluetooth low energy ios and android devices are able connect with each other over a standard bluetooth low energy (ble) connection ditto supports both bluetooth 4 x and 5 x protocols seamlessly bluetooth 5 devices are able to communicate with each other over a higher bandwidth (an average of 1 8 megabits per second) if a bluetooth 5 x device needs to connect with a bluetooth 4 x device, the devices will connect over a bluetooth 4 x protocol what are the device and operating system requirements? ditto offers a large range of devices and os support for each of our sdks for specific support see the compatibilty map for your given language docid\ svsg auykclo2o4o scy4 how does ditto still enable offline data? at the heart of ditto is a realtime database that takes in json like data structures that means that even if a device with ditto is completely disconnected from other devices, it will still have the data stored locally that means even in a completely offline environment, users will still be able to edit, read, and observe data when devices reconnect, they will exchange relevant information that was edited when they were offline you can think of this as a similar behavior to google docs or google sheets is there backward compatibility when upgrading? yes we follow semantic versioning so only versions where the major version number changes will potentially contain breaking changes that won't be backwards compatible for example, version 1 2 2 will be compatible with all previous 1 x releases, but may not be compatible with version 2 0 0 how fast does the sdk follow the ios version update? we aim to have a version of the ios sdks that is compatible with latest ios version before the ios version has been made available to the public we will likely publish alpha or beta releases of the sdks during the ios beta period, if necessary battery how much does the sdk consume battery? the sdk is designed to be as power efficient as possible we strive to keep cpu and network usage to a minimum does the ios low power mode affect the performance? ditto should not be affected in most circumstances, although background sync on ios may become less reliable performance does having a device in airplane mode affect the performance? ditto can be used in airplane mode if bluetooth or wifi is manually toggled on after selecting airplane mode, then ditto will be able to sync using those modes how fast is the sync? wifi the full speed of your connection, typically 1 gigabyte of data in times as low as 8 seconds wifi direct similar to wifi speeds bluetooth le typically 20 kb/second (however, if you’re using a device that is below android 10, then ditto will use ble gatt which is only 4 kb/second ) the big peer 40k transactions per second (25k write txns + 15k reads) how much data can ditto hold? how big can a ditto document be? there isn't a size limit to a ditto document or store like other databases, ditto will use as much data as you insert into the device controlling the size of ditto in your app is completely up to your discretion are there any limits to the number of collections? no there are no limits to the number of collections while there is no limit, try to keep the names shorter than 30 characters the collection names are stored with each document this is merely a suggestion how much memory does ditto consume during high load times? your results may vary depending on the size of your documents and the number of them you are querying ditto will temporarily store all queried documents in the memory and convert them to a format that your programming language can understand however, this process can consume a significant amount of memory if your queries are very broad you can use sort and limit together https //docs ditto live/android/common/concepts/querying#sort to capture only the most recent and relevant documents if you need to deserialize an extensive list of documents, we recommend using the observewithnextsignal function, as it allows your application to better manage memory usage (learn more at https //docs ditto live/ios/quick tips/avoiding excessive memory consumption ) bluetooth what is the difference between bluetooth classic and bluetooth low energy? bluetooth classic is an older mode used for accessories like headphones it requires a manual pairing procedure between devices ditto does not use bluetooth classic bluetooth low energy (ble) is a more recent mode of bluetooth that consumes less power and removes the need for user interaction when connecting to another device ditto's bluetooth synchronization employs this mode exclusively for a more detailed explanation, please look to our blog post https //ditto live/blog/whats the difference between btclassic and ble does the sdk require bluetooth pairing? no ditto uses exclusively bluetooth low energy, which does not require pairing how does the sync work if devices have different ble versions? ditto will take advantage of features in newer versions of ble when they are supported by both devices these features are optional, and ditto sync will work with even the earliest ble hardware adapters what is the range for bluetooth connections? approximately 100 metres (tested in the open with modern apple hardware) newer hardware usually performs better does the sync still work if the smartphone is connected to audio devices via bluetooth? yes, bluetooth low energy sync can operate at the same time as other bluetooth devices such as headphones database/sync can i sync data with devices that i am not directly connected to in the mesh? yes all participating devices must be subscribing to the same data query can multiple apps share a database? no ditto does not support more than one app using the database at the same time can i explicitly control the start and end of synchronization? yes the ditto sdk provides startsync() and stopsync() methods that will enable and disable network sync will the app sync in the background? ios offers best effort background sync provided bluetooth le is enabled and the bluetooth central and peripheral background modes are enabled android can sync in the background over wifi does the sync happen even when the device is locked? see above about background mode is there a limit to the amount of data? this will depend on the type of data, query complexity and the performance required as a rule of thumb, a small peer such as the mobile sdk is designed to handle up to 2gb of key value data and tens of thousands of documents in a collection data synced using the file attachments api is stored outside the main database and does not contribute towards the 2gb even very large attachments are supported and the limits will depend mostly on the storage and network bandwidth available on your device what happens if data is changed by multiple devices at the same time? the data will be merged when the data from one device reaches the other device is there a transaction feature? yes you can perform multiple updates, across multiple documents in multiple collections, inside a single write transaction you can do this by using the store write() functionality connection can you track the connection status of all devices in real time? ditto provides a presence viewer ui on ios and android that can be launched within your app to show all active connections to other devices this information can also be accessed programmatically using the ditto presence sdk function can i detect a loss of connection? if a device is disconnected, this will be reflected through the ditto presence observe() callback can i specify the connection type? you can specify which transport types to enable, e g bluetooth only, wifi only, or everything ditto will use its own algorithms to decide which devices to connect to and which modes to use ditto always prioritizes the fastest connection that is available, and will optimistically upgrade to a faster connection whenever possible how can i show how many peers are connected? if, separate to ditto, you know the complete list of devices in your team then you can use the ditto presence functionality provided by the sdk to keep track of which devices are online therefore you'll be able to determine which devices are offline if you don't maintain a separate list of devices in your team then the best you can currently do is to keep track of all devices that ditto sees, again by making use of the ditto presence api you can then use this list of all known devices to keep track of which of those are online/offline at any given moment how can i profile ditto related network traffic and data usage? use the instruments tool that ships with xcode to monitor both bytes and packets sent and received from a process on a macos, as well as on a simulated ios device for low level, yet powerful monitoring, use wireshark or similar tool to analyze all wifi and bluetooth traffic in a given area, and then filter the results by mac address or similar identifiers since all ditto traffic is encrypted, you can only monitor packet bytes that are sent and received; individual protocol messages cannot be recovered can i use both connectivity types (device device and device server device) at the same time? yes you can use both direct communication between small peers (device to device) and communication by way of a server ( docid\ k51z knujnm0ge8aqkhba ) that connects and transmits data between small peers (device to server to device) this dual approach provides flexibility — your app remains efficient in any network environment and you control when and what routes through a central server however, web browsers do not support peer to peer transports that means a web app will only be able to connect to the big peer over websockets (see docid\ dmlp pempfsu1kye4t4de ) it should not affect the performance of the android and angular apps if you see any performance degradation, please let us know as soon as possible security is the data in the database encrypted? ditto does not encrypt its database, however both ios and android offer disk encryption to protect your data in case a device is stolen, provided a screen lock code has been set how can i limit the devices the sdk can connect to? ditto will only connect to devices that advertise the same "application name" further controls are under development please speak to us for advice if you have special requirements for limiting connections is the communication encrypted? communication is encrypted using tls 1 3 and peer identities are verified using certificates this is the same state of the art technology used in web browsers it applies to every communication mode from bluetooth to wifi how can i control what data can or cannot be synced? the certificates that you provide to devices contain a set of permissions you can use these permissions to specify whether or not a given device should be able to access given data if you only want a device to sync a subset of the data that it has access to then you do this by only using queries for that device's live queries and subscriptions that relate to the data that you wish to be synced can other apps with the ditto sdk intercept the communication? ditto provides multiple production security modes that robustly protect against eavesdropping you can either use a shared secret key, or device specific keys with a central authority ditto also has a development security mode which does not require you to provide a key this is not secure, and provided for ease of development how does the certificate work? ditto certificates are standard x 509 certificates each device has a keypair and the certificate grants that device a unique id and rules for which collections and documents it is permitted to read and write organizations with strict on premises requirements may operate their own certificate authority (ca) certificates can also be generated and distributed automatically from the ditto big peer service for more information about certificate deployments please speak to us wi fi can android and ios devices sync with each other over wifi direct using ditto? no android wi fi direct is, at least for now, only capable of syncing with other android devices apple devices running ios and macos are capable of syncing over apple wireless direct these two transports are not compatible with each other however, other transports like bluetooth low energy and access points will be able to sync with each other just fine api documentation see the api reference on the sidebar to the left you can also use your ide's "jump to definition" feature