Skip to main content

Online Playground

When you install Ditto in a client device like a web, desktop, mobile, or IoT application, you are installing a Small Peer. Running on the cloud is a Big Peer. While it still looks like any peer, underneath the hood, a Big Peer is capable of scaling to meet the demands of large amount of data.

Online Playground

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 get started, you can synchronize with the Ditto Big Peer using the Online Playground. These apps can sync with the Big Peer if they have the same appID. 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

Online Playground 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

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:

Online Playground enabled in the Ditto Portal

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.

New and Improved Docs

Ditto has a new documentation site at https://docs.ditto.live. This legacy site is preserved for historical reference, but its content is not guaranteed to be up to date or accurate.