Skip to main content
To retrieve your SDK connection details ensure you have first:
  1. Created A Ditto Portal Account - Creating a Ditto Account
  2. Created A Ditto Database - Creating a New Database
After you’ve created your database, select it from the list. On the Connect tab, you will see the following details under Big peer connection information:
  • Database ID - The unique identifier for your database.
  • 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.

Offline License Tokens

Offline license tokens allow your application to operate without connectivity to Ditto’s cloud. They are available on the Connect tab for your database in the Portal. Offline license tokens have an expiration period. The default expiration is 30 days, but you can customize this when creating a new token.

Required Permissions

To view offline license tokens, your Portal role must include the Access offline-only licenses permission. To create or manage offline license tokens, your role must also include the Request offline-only licenses permission. For details on configuring roles, see Role-Based Access Control.
If you do not see the offline license token section on the Connect tab, your role may not have the required permissions. Contact your organization admin to request the Access offline-only licenses and/or Request offline-only licenses permissions, or reach out to Ditto support to have tokens generated on your behalf.

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")
}

// 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)
}