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.
-
Add the SDK to your app’s project: in Android Studio, the Maven folder (
vendor/wallet-maven) and the librariescom.wallet.sdk:sdk-coreandsdk-ui-compose(andsdk-facefor the face check); in Xcode,Wallet.xcframework(Embed & Sign),-lsqlite3and thecompose-resourcesfolder. Step by step: Install & versions. -
Create the wallet once, when your app starts (
Application.onCreateon Android, yourApp’siniton iOS), and keep it: where credentials come from, and which verifiers to name as trusted.WalletSetup.kt package samplesimport com.wallet.Walletimport com.wallet.WalletSdkimport com.wallet.config.IssuerConfigimport 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}WalletSetup.swift import Wallet/// The SDK object for a wallet app. Created once, when the app starts, and kept.enum WalletSetup {/// One configuration for the app and its Digital Credentials provider extension (they share the store).static func config(signedReaderList: KotlinByteArray) -> SdkConfig {Wallet.shared.walletConfig(// Where credentials come from: your OpenID4VCI issuer.issuer: IssuerConfig(baseUrl: "https://issuer.example.com",clientId: "my-wallet",redirectUri: "mywallet://callback",dpopPolicy: .allowBearerFallback),// 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: [EmiratesIdType.type],// A check before sharing, e.g. the face check (see Prove it's you). nil: share on consent.shareGuard: nil,// The App Group the app shares with its provider extension (the phone's ID sheet). nil: none.iosAppGroupId: "group.com.example.wallet")}static func create(signedReaderList: KotlinByteArray) -> WalletSdk {Wallet.shared.create(config: config(signedReaderList: signedReaderList))}}/// Shared by the samples: the one SDK instance of the app.enum MyWallet {static let sdk = WalletSetup.create(signedReaderList: KotlinByteArray(size: 0)) // your signed reader list} -
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 samplesimport android.os.Bundleimport androidx.activity.compose.BackHandlerimport androidx.activity.compose.setContentimport androidx.compose.foundation.backgroundimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.Rowimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.heightimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.safeDrawingPaddingimport androidx.compose.material3.AlertDialogimport androidx.compose.material3.Cardimport androidx.compose.material3.IconButtonimport androidx.compose.material3.MaterialThemeimport androidx.compose.material3.NavigationBarimport androidx.compose.material3.NavigationBarItemimport androidx.compose.material3.Textimport androidx.compose.material3.TextButtonimport androidx.compose.runtime.Composableimport androidx.compose.runtime.getValueimport androidx.compose.runtime.mutableStateOfimport androidx.compose.runtime.rememberimport androidx.compose.runtime.saveable.rememberSaveableimport androidx.compose.runtime.setValueimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifierimport androidx.compose.ui.platform.LocalContextimport androidx.compose.ui.unit.dpimport androidx.fragment.app.FragmentActivityimport com.wallet.ScannedCodeimport com.wallet.WalletSdkimport com.wallet.ui.CredentialOfferSheetimport com.wallet.ui.WalletActionPillimport com.wallet.ui.WalletBrandingimport com.wallet.ui.WalletLinkPresentmentimport com.wallet.ui.WalletPresentScreenimport com.wallet.ui.WalletPromptDialogsimport com.wallet.ui.WalletScanScreenimport 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 })}}}}@Composableprivate 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. */@Composablefun 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 = falsewhen (val scanned = ScannedCode.classify(code)) {is ScannedCode.CredentialOffer -> offerUri = scanned.uri // an issuer's offer: the sheet belowis ScannedCode.PresentationRequest -> WalletLinkPresentment.start(context, sdk, scanned.uri) // a website's request: the SDK's screenis 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 aFragmentActivity.HostApp.swift import SwiftUIimport Wallet/// Your app stays the app: your home screen, your tiles. One tile, "Documents", opens the wallet.struct HostHome: View {@State private var documents = falsevar body: some View {Group {if documents {DocumentsScreen(onBack: { documents = false })} else {VStack(alignment: .leading, spacing: 16) {Text("My Hub").font(.title2.bold())Button("Documents") { documents = true } // one of your tilesSpacer()}.padding(24)}}// Credential offers and website requests that open the app go to the wallet..onOpenURL { url inif WalletViewControllersKt.handleWalletUrl(url: url.absoluteString, sameDevice: true) { documents = true }}}}/// "‹ My Documents" over the SDK's wallet (cards, Scan | Present, consent), with your tab bar below it.struct DocumentsScreen: View {var onBack: () -> Voidvar body: some View {VStack(spacing: 0) {// Your title bar.HStack(spacing: 12) {Button(action: onBack) { Image(systemName: "chevron.left").font(.title3.weight(.semibold)) }Text("My Documents").font(.headline)Spacer()}.padding(.horizontal, 16).frame(height: 44)// The wallet, without its own heading: your bar above is the title.EmbeddedWallet()// Your tab bar.HStack {Spacer(); Button(action: onBack) { Label("Home", systemImage: "house") }Spacer(); Label("Services", systemImage: "square.grid.2x2"); Spacer()}.frame(height: 50)}.background(Color(red: 0.97, green: 0.96, blue: 0.98)) // the same colour as WalletBranding.backgroundColor}}/// The SDK's wallet screen, hosted in SwiftUI. `title: nil` hides its heading; `pillShadow: false` because the/// Scan | Present pill sits just above your own tab bar.struct EmbeddedWallet: UIViewControllerRepresentable {func makeUIViewController(context: Context) -> UIViewController {WalletViewControllersKt.WalletViewController(sdk: MyWallet.sdk, title: nil, pillShadow: false)}func updateUIViewController(_ controller: UIViewController, context: Context) {}}WalletViewController(sdk:title:pillShadow:)withtitle: nilhides the SDK’s heading. Pass the links that open your app tohandleWalletUrl, so offers and website requests reach the wallet.The pill, Back, your page colour and the scanner are explained in Fit it into your screens.
-
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 samplesimport com.wallet.WalletSdkimport com.wallet.model.SampleMdlimport com.wallet.model.SdkResultimport 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 parsereturn null}}SampleCards.swift import Wallet/// 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.enum SampleCards {/// First launch: when the wallet holds nothing, add a driving licence and an Emirates ID./// `portrait` is the holder's photo as JPEG bytes, `signature` their signature as PNG bytes (both optional).static func addIfEmpty(sdk: WalletSdk, portrait: KotlinByteArray?, signature: KotlinByteArray?) {Task.detached {var done = falsetry? await sdk.wallet.credentials().collect(collector: Collector<[CredentialSummary]> { list inguard list.isEmpty, !done else { return }done = trueTask { if let error = try? await add(sdk: sdk, portrait: portrait, signature: signature) { print("Sample cards: \(error)") } }})}}/// Adds the two cards. Returns an error message if one failed.private static func add(sdk: WalletSdk, portrait: KotlinByteArray?, signature: KotlinByteArray?) async throws -> String? {// The built-in driving licence (fictional holder, photo, privileges): sdk.wallet.addSampleMdl().// Or your own holder; anything left nil 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.let licence = try await sdk.wallet.addSampleMdl(sample: SampleMdl(givenName: "Alex", familyName: "Tan", birthDate: "1991-05-13",documentNumber: "987654321", issuingAuthority: "Roads and Transport Authority",issuingCountry: "AE", portrait: portrait,values: ["given_name_national_character": "أليكس", // the name in the holder's own script"family_name_national_character": "تان","nationality": "Singaporean","sex": "1", // the ISO code, as digits"birth_place": "Singapore","resident_address": "Villa 12, Al Wasl Road, Dubai","resident_city": "Dubai","resident_country": "AE","un_distinguishing_sign": "UAE","issuing_jurisdiction": "Dubai",],signature: signature))if let failed = licence as? SdkResultFailure { return failed.error.message }// One of your own document types: every id must be one the type declares, every value as text.let id = try await sdk.wallet.addSampleCredential(type: EmiratesIdType.type, values: ["given_name": "Alex","family_name": "Tan","birth_date": "1991-05-13", // dates: YYYY-MM-DD"sex": "1", // the ISO code, as digits"expiry_date": "2034-05-19","person_id": "784-1991-1234567-1",], portrait: portrait) // JPEG bytes for the type's picture element, or nilif let failed = id as? SdkResultFailure { return failed.error.message } // PARSE: an unknown id, or a value that doesn't parsereturn nil}}Value formats and errors: Sample credentials.
-
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.