Skip to main content

Quick Start

This page walks the whole path: configure the SDK, sign a user in, find one of their avatars, and render it.

Steps 1–3 use the Auth and Inventory modules; step 4 uses NAF. See the Partner SDK API for the modules, or the NAF API for rendering.

1. Configure and sign in​

Configure once at launch, before any other call. Genies issues you an app ID; the environment supplies the hosts.

The simplest path is to let GeniesAuth configure the core runtime for you in a single call:

import com.genies.auth.GeniesAuth
import com.genies.auth.GeniesEnvironment

GeniesAuth.initializeWithAppId(
context,
environment = GeniesEnvironment.PRODUCTION,
appName = "YourApp",
appId = appId,
)

An app ID on its own is everything magic-link sign-in needs. A client ID is only required for federated sign-in.

note

If you'd rather bring the core runtime up first — to start notifications early, say — call GeniesSDK.configure(...) and then GeniesAuth.initialize(context) to attach. Don't do both: a value-carrying initialize(...) after GeniesSDK.configure(...) fails with "GeniesSDK core is already configured."

2. Sign the user in​

Magic link is the recommended flow: Genies sends a one-time code to an email address or phone number, and you verify it.

val start = GeniesAuth.startMagicLink(email = email)
// Genies sends the code. `start.expiresAt` says how long it's good for.

// Collect the code from the user, then:
val result = GeniesAuth.verifyMagicLink(code = code, email = email)
// Session is established; Inventory calls can now be made.

Pass phoneNumber instead of email to do the same over SMS. The number must be E.164 — country code included, 7–15 digits, no spaces or dashes — like +12345678901.

If Genies also issued you a client ID, federated sign-in is available through GeniesAuth.signIn(activity, redirectUri, scope). The redirect is an App Link your app has registered; forward it from your activity with GeniesAuth.handleRedirect(uri), which returns null when no federated sign-in was pending.

Observe session changes through GeniesSDK.credentialState, a StateFlow:

lifecycleScope.launch {
GeniesSDK.credentialState.collect { event ->
// event.state, event.reason
}
}

3. Find an avatar​

The Inventory module returns identifiers and display data — names and icons for building a picker — not models or textures.

import com.genies.inventory.GeniesInventory
import com.genies.inventory.GeniesAvatarKind

val inventory = GeniesInventory()
val avatars = inventory.listOwnedAvatars(kind = GeniesAvatarKind.SmartAvatar)

// Build your picker from `name`; `canChat` is true for smart avatars.
val selected = avatars.first()
val ref = selected.ref

Use getAvatar(ref) for the shared catalog view of an avatar, or getUserAvatar(ref) for the signed-in user's personalized view.

4. Render it with NAF​

The reference from step 3 is what you hand to NAF.

Loading on Android

Android NAF loads avatars from an avatar definition. The identifier-based loading that iOS uses — handing NAF a GeniesAvatarRef straight from the Inventory module — hasn't reached Android yet.

// One-time process init
NafContainerApi.init(this, NafKitConfig.normalizedResolverConfig(this))
NafDefaultAssets.ensureLoaded(this)

// Drop a NafView and load an avatar
val view = NafView(this)
setContentView(view)

view.onSurfaceReady = {
lifecycleScope.launch {
val avatar = NafAvatar.fromJson(assets.open("avatar.json").bufferedReader().readText())
view.session.loadAvatar(avatar) // default mode = Animated()
}
}

view.applyDefaultToonPreset() // bundled "default" toon preset
view.frameAvatar() // camera framing

Common NAF operations​

Once an avatar is loaded, NafView exposes the usual controls:

// Wearables
view.session.equip(NafAssetEntry("hat_001"))
view.session.unequip("hat_001")

// Camera
view.cameraDistance = 2.5f
view.frameAvatar()

// Lighting
view.lighting.setKeyLightDirection(45f, 10f)
view.lighting.setExposure(1.2f)

// Picking and gizmo
view.isPickingEnabled = true
view.isGizmoEnabled = true
view.onPick = { hit -> view.isGizmoVisible = (hit != null) }

// Frame rate
view.adaptiveFrameRate = true
view.preferredFramesPerSecond = 60
view.renderScale = 0.75f

// Teardown
view.unloadAvatar()

Next steps​