Skip to content

Quickstart

This is CityNow’s Documents tile, reduced to the parts you copy. Every Kotlin block is compiled, and every Swift block type-checked, against the SDK before each release.

You need Android Studio or Xcode, the SDK zip, your existing app, and a phone to run it on. About an hour.

  1. Add the SDK to your app’s project: in Android Studio, the Maven folder (vendor/wallet-maven) and the libraries com.wallet.sdk:sdk-core and sdk-ui-compose (and sdk-face for the face check); in Xcode, Wallet.xcframework (Embed & Sign), -lsqlite3 and the compose-resources folder. Step by step: Install & versions.

  2. Create the wallet once, when your app starts (Application.onCreate on Android, your App’s init on iOS), and keep it: where credentials come from, and which verifiers to name as trusted.

    WalletSetup.kt
    package samples
    import com.wallet.Wallet
    import com.wallet.WalletSdk
    import com.wallet.config.IssuerConfig
    import com.wallet.config.TrustedVerifiers
    /** The SDK object for a wallet app. Create it once, when the app starts, and keep it. */
    object WalletSetup {
    fun create(signedReaderList: ByteArray): WalletSdk = Wallet.createWallet(
    // Where credentials come from: your OpenID4VCI issuer.
    issuer = IssuerConfig(
    baseUrl = "https://issuer.example.com",
    clientId = "my-wallet",
    redirectUri = "mywallet://callback",
    ),
    // The verifiers named on the consent sheet; others show as "Unknown requester".
    trustedVerifiers = TrustedVerifiers(signedList = signedReaderList),
    // Document types you hold besides the built-in driving licence.
    credentialTypes = listOf(EmiratesIdType.type),
    // A check before sharing, e.g. the face check (see Prove it's you). Null: share on consent.
    shareGuard = null,
    )
    }
    /** Shared by the samples: the one SDK instance of the app. */
    object App {
    lateinit var sdk: WalletSdk
    }
  3. Open it from your tile. Your title bar above, your tab bar below, the wallet in between. The wallet draws no heading of its own, so your bar is the title; Back returns to your home.

    HostAppTile.kt
    package samples
    import android.os.Bundle
    import androidx.activity.compose.BackHandler
    import androidx.activity.compose.setContent
    import androidx.compose.foundation.background
    import androidx.compose.foundation.layout.Box
    import androidx.compose.foundation.layout.Column
    import androidx.compose.foundation.layout.Row
    import androidx.compose.foundation.layout.fillMaxSize
    import androidx.compose.foundation.layout.fillMaxWidth
    import androidx.compose.foundation.layout.height
    import androidx.compose.foundation.layout.padding
    import androidx.compose.foundation.layout.safeDrawingPadding
    import androidx.compose.material3.AlertDialog
    import androidx.compose.material3.Card
    import androidx.compose.material3.IconButton
    import androidx.compose.material3.MaterialTheme
    import androidx.compose.material3.NavigationBar
    import androidx.compose.material3.NavigationBarItem
    import androidx.compose.material3.Text
    import androidx.compose.material3.TextButton
    import androidx.compose.runtime.Composable
    import androidx.compose.runtime.getValue
    import androidx.compose.runtime.mutableStateOf
    import androidx.compose.runtime.remember
    import androidx.compose.runtime.saveable.rememberSaveable
    import androidx.compose.runtime.setValue
    import androidx.compose.ui.Alignment
    import androidx.compose.ui.Modifier
    import androidx.compose.ui.platform.LocalContext
    import androidx.compose.ui.unit.dp
    import androidx.fragment.app.FragmentActivity
    import com.wallet.ScannedCode
    import com.wallet.WalletSdk
    import com.wallet.ui.CredentialOfferSheet
    import com.wallet.ui.WalletActionPill
    import com.wallet.ui.WalletBranding
    import com.wallet.ui.WalletLinkPresentment
    import com.wallet.ui.WalletPresentScreen
    import com.wallet.ui.WalletPromptDialogs
    import com.wallet.ui.WalletScanScreen
    import com.wallet.ui.WalletScreen
    /** Your app stays the app: your home screen, your tiles. One tile, "Documents", opens the wallet. */
    class HostActivity : FragmentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContent {
    var documents by rememberSaveable { mutableStateOf(false) }
    WalletBranding.theme { // the SDK's theme in your colours and typeface (see Branding.kt)
    if (documents) DocumentsScreen(App.sdk, onBack = { documents = false })
    else HomeScreen(onDocuments = { documents = true })
    }
    }
    }
    }
    @Composable
    private fun HomeScreen(onDocuments: () -> Unit) {
    Column(Modifier.fillMaxSize().safeDrawingPadding().padding(24.dp)) {
    Text("My Hub", style = MaterialTheme.typography.titleLarge)
    // One of your tiles.
    Card(onClick = onDocuments, modifier = Modifier.padding(top = 16.dp).fillMaxWidth()) {
    Text("Documents", Modifier.padding(20.dp))
    }
    }
    }
    /** "← My Documents" over the SDK's wallet (cards, details), with your tab bar below it. */
    @Composable
    fun DocumentsScreen(sdk: WalletSdk, onBack: () -> Unit) {
    var scanning by remember { mutableStateOf(false) }
    var presenting by remember { mutableStateOf(false) }
    var cardOpen by remember { mutableStateOf(false) }
    var offerUri by remember { mutableStateOf<String?>(null) }
    var scanProblem by remember { mutableStateOf<String?>(null) }
    val context = LocalContext.current
    // Back closes the scanner or the Present screen first, then returns to your home.
    BackHandler { if (scanning || presenting) { scanning = false; presenting = false } else onBack() }
    when {
    // The SDK's full-screen flows: they bring their own close button.
    scanning -> WalletScanScreen(
    onScanned = { code ->
    scanning = false
    when (val scanned = ScannedCode.classify(code)) {
    is ScannedCode.CredentialOffer -> offerUri = scanned.uri // an issuer's offer: the sheet below
    is ScannedCode.PresentationRequest -> WalletLinkPresentment.start(context, sdk, scanned.uri) // a website's request: the SDK's screen
    is ScannedCode.Unrecognized -> scanProblem = "This QR code isn't a request for your documents or a new document to add."
    }
    },
    onClose = { scanning = false },
    )
    presenting -> WalletPresentScreen(sdk, onClose = { presenting = false })
    else -> Box(Modifier.fillMaxSize().background(MaterialTheme.colorScheme.background).safeDrawingPadding()) {
    Column(Modifier.fillMaxSize()) {
    // Your title bar.
    Row(Modifier.fillMaxWidth().height(56.dp), verticalAlignment = Alignment.CenterVertically) {
    IconButton(onClick = onBack) { Text("‹", style = MaterialTheme.typography.headlineMedium) }
    Text("My Documents", style = MaterialTheme.typography.titleLarge)
    }
    // The wallet, without its own heading: your bar above is the title.
    WalletScreen(sdk, Modifier.weight(1f), onCardOpen = { cardOpen = it }, title = null)
    // Your tab bar.
    NavigationBar {
    NavigationBarItem(selected = true, onClick = onBack, icon = { Text("⌂") }, label = { Text("Home") })
    NavigationBarItem(selected = false, onClick = {}, icon = { Text("☰") }, label = { Text("Services") })
    }
    }
    // The SDK's Scan | Present pill, just above your tab bar. No shadow, so the two don't stack.
    if (!cardOpen) {
    WalletActionPill(
    onScan = { scanning = true }, onPresent = { presenting = true }, shadow = false,
    modifier = Modifier.align(Alignment.BottomCenter).padding(bottom = 96.dp),
    )
    }
    }
    }
    offerUri?.let { CredentialOfferSheet(sdk, it, onDone = { offerUri = null }) }
    // Anything else that was scanned: say so, instead of silently doing nothing.
    scanProblem?.let { message ->
    AlertDialog(
    onDismissRequest = { scanProblem = null },
    confirmButton = { TextButton(onClick = { scanProblem = null }) { Text("OK") } },
    title = { Text("Not a document request") },
    text = { Text(message) },
    )
    }
    WalletPromptDialogs() // the consent sheet and the permission prompts, over everything
    }

    WalletScreen(sdk, title = null) hides the SDK’s heading. Host it in a FragmentActivity.

    The pill, Back, your page colour and the scanner are explained in Fit it into your screens.

  4. Get cards. Sample cards now, your issuer later. They are signed by the SDK’s sample issuer, which the demo verifiers and the Verify API accept, so they present and verify like real ones. Add them once, when the wallet is empty.

    SampleCards.kt
    package samples
    import com.wallet.WalletSdk
    import com.wallet.model.SampleMdl
    import com.wallet.model.SdkResult
    import kotlinx.coroutines.flow.first
    /**
    * Sample cards until your issuer is live. They are signed by the SDK's sample issuer, which the demo
    * verifiers and the Verify API accept, so they present and verify like real ones.
    */
    object SampleCards {
    /**
    * Adds a driving licence and an Emirates ID once, when the wallet is empty. Returns an error message if one failed.
    * [portrait] is the holder's photo as JPEG bytes, [signature] their signature as PNG bytes (both optional).
    */
    suspend fun ensure(sdk: WalletSdk, portrait: ByteArray?, signature: ByteArray?): String? {
    if (sdk.wallet.credentials().first().isNotEmpty()) return null
    // The built-in driving licence (fictional holder, photo, privileges): sdk.wallet.addSampleMdl().
    // Or your own holder; anything left null keeps the built-in value. `values` sets any other
    // org.iso.18013.5.1 element by its ISO name, as text; `signature` is the signature on the card.
    val licence = sdk.wallet.addSampleMdl(
    SampleMdl(
    givenName = "Alex", familyName = "Tan", birthDate = "1991-05-13",
    documentNumber = "987654321", issuingAuthority = "Roads and Transport Authority",
    issuingCountry = "AE", portrait = portrait,
    values = mapOf(
    "given_name_national_character" to "أليكس", // the name in the holder's own script
    "family_name_national_character" to "تان",
    "nationality" to "Singaporean",
    "sex" to "1", // the ISO code, as digits
    "birth_place" to "Singapore",
    "resident_address" to "Villa 12, Al Wasl Road, Dubai",
    "resident_city" to "Dubai",
    "resident_country" to "AE",
    "un_distinguishing_sign" to "UAE",
    "issuing_jurisdiction" to "Dubai",
    ),
    signature = signature,
    ),
    )
    if (licence is SdkResult.Failure) return licence.error.message
    // One of your own document types: every id must be one the type declares, every value as text.
    val id = sdk.wallet.addSampleCredential(
    EmiratesIdType.type,
    mapOf(
    "given_name" to "Alex",
    "family_name" to "Tan",
    "birth_date" to "1991-05-13", // dates: YYYY-MM-DD
    "sex" to "1", // the ISO code, as digits
    "expiry_date" to "2034-05-19",
    "person_id" to "784-1991-1234567-1",
    ),
    portrait, // JPEG bytes for the type's picture element, or null
    )
    if (id is SdkResult.Failure) return id.error.message // PARSE: an unknown id, or a value that doesn't parse
    return null
    }
    }

    Value formats and errors: Sample credentials.

  5. Run it on a phone (Android Studio: Run ▶; Xcode: ⌘R): Bluetooth and the camera don’t work in emulators or simulators. Tap your tile, tap Present, and read the card with the Verify app on a second phone. Then tap Back: your home screen.

The wallet still looks like the SDK’s: your name, colours, typeface and card designs are one object, set in the same place as step 2 (Make it look like your app). The face check before a protected card is shared is one shareGuard line (Prove it’s you).

Next: Fit it into your screens.