Initialization
A Ditto application is the way to separate data synchronization into separate
logical segments or environments. Each Ditto application has an AppID
which is
a random universally unique identifier (UUID). A UUID is a randomly generated string of alphanumeric characters that ensures that your app is distinctly identified across Ditto, as well as all other systems and environments.
Peers that have the same AppID
can sync with each other. Online Playground
applications have no restrictions to data. Online playgrounds are perfect
for learning about how to use Ditto's APIs.
- Apps with Online Playground can read and write to all collections.
- Apps with Online Playground will connect to other peer devices or a Big Peer app with same appID.
Going offline
info
If you want to use Ditto in an airgapped environment that is entirely offline, or on-premise, please open the chat bot on the bottom-right hand corner and click "Upgrade account" to talk to a team member.
Each small peer needs to first synchronize with the Ditto Big Peer using the Online Playground identity. Onine Playground is a way to use ditto for development. Devices must connect to the internet first before going offline. Once the device connects to the internet, it creates a certificate that can be used to authenticate while offline. Once offline, the device can synchronize for one week. After one week, the certificate will expire, and the device must re-connect to the Internet to get a new certificate.
This one week expiration is a setting that you can customize. Use OnlineWithAuthentication if a device needs to be offline for more or less than one week.
DittoLogger.minimumLogLevel = .debuglet ditto = Ditto(identity: .onlinePlayground( appID: "REPLACE_ME_WITH_YOUR_APP_ID", token: "REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN"))do { try ditto.startSync()} catch (let err) { print(err.localizedDescription)}
Get your appID
caution
DO NOT deploy a public binary version of the application (e.g., to an App Store) with Online Playground. We call this a Playground because it's meant for getting started quickly on trusted devices.
For using the Big Peer with an OAuth client suitable for untrusted devices, use Online With Authentication.
To find your AppID, go to your app in the Ditto portal and find the Authentication Mode & Webhook Settings section. Ensure that "Playground" is selected like so:
How it works
Online Playground requires that devices must first connect to the Big Peer to create a X.509 certificate. This certificate ensures that devices are allowed to synchronize with each other either offline or online. Online Playground allows anyone to synchronize until the certificate expires.