Skip to main content

Quickstart

Add the Octopus SDK to your app, initialize it, open the community and connect your signed-in user. Pick your platform once: every tab below follows it.

Before you begin​

  • A sandbox API key. Octopus creates two communities for you, a sandbox and a production one, each with its own API key. Use the sandbox key while you integrate, so your test content never reaches your real users.
  • A supported toolchain. Check the minimum OS and tool versions in Requirements.
  • Optional: a token route on your backend. Connecting your own users needs a JWT signed by your backend. You can install the SDK and open the community first, then add the route with Generate a signed JWT.

1. Install the SDK​

The SDK is published on Maven Central. Add it to your app module, with Navigation Compose to host its screens:

// app/build.gradle.kts
dependencies {
implementation("com.octopuscommunity:octopus-sdk:1.14.2")
implementation("com.octopuscommunity:octopus-sdk-ui:1.14.2")
implementation("androidx.activity:activity-compose:1.10.1")
implementation("androidx.navigation:navigation-compose:2.9.5")
}

Your app needs mavenCentral() in its repositories, minSdk 21 or higher and Jetpack Compose with Material 3.


2. Initialize the SDK​

Initialize the SDK once, when your app starts, with your API key. The examples below use the SSO connection mode with no app-managed fields: your app signs users in, and members edit their community profile inside the community. To let your app own the nickname, bio or picture, or to let Octopus run its own sign-in flow, see Connect your users.

Call OctopusSDK.initialize from your Application:

import android.app.Application
import com.octopuscommunity.sdk.OctopusSDK
import com.octopuscommunity.sdk.domain.model.ConnectionMode

class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
OctopusSDK.initialize(
context = this,
apiKey = "YOUR_API_KEY",
connectionMode = ConnectionMode.SSO(),
)
}
}

3. Show the community​

Open the community from one entry point in your app, such as a button or a tab. Display the community covers every other way to present it.

Host OctopusHomeScreen in a NavHost, and register the SDK's other screens with octopusComposables. In SSO mode, onNavigateToLogin opens your sign-in screen:

import com.octopuscommunity.sdk.ui.home.OctopusHomeScreen
import com.octopuscommunity.sdk.ui.octopusComposables

setContent {
val navController = rememberNavController()
NavHost(navController = navController, startDestination = "community") {
composable("community") {
OctopusHomeScreen(
navController = navController,
onNavigateToLogin = { /* Open your sign-in screen */ },
)
}
octopusComposables(
navController = navController,
onNavigateToLogin = { /* Open your sign-in screen */ },
)
}
}

4. Connect your user​

When a user signs in to your app, pass their id to connectUser with a token provider. The SDK calls the token provider each time it needs a fresh JWT, which your backend signs (see Generate a signed JWT). Until then, members browse the community as guests. Call disconnectUser when they sign out. Error handling, profile fields and entitlements are covered in Connect your users.

connectUser is a suspending function that returns an OctopusResult:

import com.octopuscommunity.sdk.domain.model.ClientUser
import com.octopuscommunity.sdk.domain.network.OctopusResult

viewModelScope.launch {
val result = OctopusSDK.connectUser(
user = ClientUser(userId = user.id),
tokenProvider = { yourBackend.fetchOctopusToken(user.id) },
)
if (result !is OctopusResult.Success) {
// The connection was refused: see Connect your users
}
}

5. Run and verify​

Run your app and open the community from your entry point. You should see the community home feed with the posts of your sandbox community. Before connectUser, trying to post opens your sign-in flow; after it, the member can post, comment and react under their own profile.

If it does not work:

  • The feed stays empty or shows an error. Check that the API key is the sandbox key of the community you expect and that initialization runs before the community opens.
  • The member stays a guest after connectUser. The token was refused: your backend must sign it with the secret of the same community as the API key. Read the error returned by connectUser (Connect your users).
  • The app crashes when the first community screen opens. A platform requirement of 1. Install the SDK is missing: check the notes in your platform tab.

Next steps​