Prerequisites

Ditto’s C++ Android Quickstart supports Android. Before getting started, ensure you have the following:

Get Started

1. Clone the Repository

  1. Open the terminal
  2. Clone the repository from GitHub.
    git clone https://github.com/getditto/quickstart
  3. Navigate to the project directory:
    cd quickstart

2. Configure Ditto

Get Ditto App ID and Playground Token

  1. Log in to your Ditto Portal account
  2. Navigate to your application and obtain the Ditto App ID and Playground Token (see Getting SDK Connection Details for more details)

Add Ditto Credentials

  1. Copy the .env.template file at the top level of the quickstart repo to .env and add your app ID and online playground token.
    cp .env.sample .env
    
  2. Update the .env file with the App ID and Playground Token from your Ditto Application
    DITTO_APP_ID="REPLACE_ME_WITH_YOUR_APP_ID"
    DITTO_PLAYGROUND_TOKEN="REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN"
    
  1. Navigate to the project directory

    cd android-cpp/QuickStartTasksCPP
    
  2. Download Ditto.tar.gz and unpack an archive containing the libditto.a static library and Ditto header.

    curl -O https://software.ditto.live/cpp-linux-x86_64/Ditto/4.8.2/dist/Ditto.tar.gz && tar xvfz Ditto.tar.gz
    
  3. Add the ./sdk directory to your compiler’s include and linker directories, and link the ditto library into your application. For example:

    g++ -std=c++17 ./src/main.cpp -I ./sdk -lditto -ldl -lrt -pthread -L ./sdk -o dist/main;
    # Once executed, your output will be available at: ./dist/main
    

3. Run the Application

  1. Launch Android Studio and open the quickstart/cpp-android directory.
  2. In Android Studio, select a connected Android device, or create and launch an Android emulator and select it as the destination, then choose the Run > Run 'app' menu item.

4. Sync-Data Offline

  1. Launch the application on multiple devices or simulators
  2. Disconnect from your current WiFi network while keeping WiFi enabled on the device to allow for LAN connections
  3. Add, edit, and delete tasks and experience offline collaboration!

Next Steps

All the Ditto Quickstart apps works together! Try running a quickstart app in other languages and see them all collaborate.

Additional Resources