To retrieve your SDK connection details ensure you have first:

  1. Created A Ditto Portal Account - Creating a Ditto Account
  2. Created A Ditto App - Creating a New App

After you’ve created your app, select it from the list.

On the Connect tab, you will see the following details under Big peer connection information:

  • App ID - The unique identifier for your app.
  • Auth URL - This is the URL you will need to pass to your SDK to authenticate.
  • Websocket URL - This is the URL you will need to pass to your SDK to initiate replication via Websocket to Ditto Server.

On the Connect tab, under Authentication Mode, if you are still using the default authentication settings, you will also see the Online Playground Authentication Token. This token is used to authenticate your SDK to Ditto Server It allows you to explore Ditto platform features and functionality without the hassle of setting up your own authentication mechanism.

Connecting an SDK

Below are some examples of how to connect an SDK to Ditto Server:

ditto = Ditto(
  identity: DittoIdentity.onlinePlayground(
    appID: "REPLACE_ME_WITH_YOUR_APP_ID",
    token: "REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN",
    enableDittoCloudSync: false, // This is required to be set to false to use the correct URLs
    customAuthURL: URL(string: "REPLACE_ME_WITH_YOUR_AUTH_URL")
  )
)

ditto.updateTransportConfig { transportConfig in
  // Set the Ditto Websocket URL
  transportConfig.connect.webSocketURLs.insert("wss://REPLACE_ME_WITH_YOUR_WEBSOCKET_URL")
  
  // P2P sync is enabled by default across all transports. Disable those
  // if you are only using Ditto Cloud Sync.
  transportConfig.setPeerToPeer(enabled: false)  
}

// Disable DQL strict mode so that collection definitions are not required in DQL queries
try await ditto.store.execute("ALTER SYSTEM SET DQL_STRICT_MODE = false")

do {
  try ditto.startSync()
} catch {
  print(error.localizedDescription)
}