Mobile SDKs
Context
zerohash supports native mobile SDKs, enabling developers to embed products directly into their iOS and Android applications with minimal effort. This addition brings faster integration, improved performance, and a more seamless user experience compared to traditional mobile-web or API-only implementations.
iOS
Github links
Requirements
- iOS 13.0+
- Swift 5.0+
- Xcode 13.0+
Installation via Xcode
-
In Xcode, select File > Add Package Dependencies...

-
Enter the repository URL:
https://github.com/connect-by-zerohash/connect-ios -
Select the version rule you want to use (we recommend
Up to Next Major Version)
-
Click Add Package
-
On the next popup, select your app target and click on
Add Package
-
Confirm that the ConnectSDK is now listed on your app's package dependencies:

-
Go to your application target and make sure that ConnectSDK is listed under
Frameworks, Libraries and Embedded Content
Integration
Follow the following steps:
- Create a View in your application that will trigger the Auth flow
- Import the SDK
- When clicking a button or other UI element, start the flow:
- Get a JWT from a backend API
- Configure the SDK appearance, environment and callbacks you want to use.
- Callbacks will return the same data described here
- Use the present method sending the View to render the SDK.
Example
Also represented in our code recipe here.
import SwiftUI
import ConnectSDK // 1. Import the SDK main class
struct ContentView: View {
// 2. Attach start function with a button or other UI element.
var body: some View {
Button("Deposit with crypto") {
startConnect()
}
}
func startConnect() {
// 3. Get a JWT from your backend
let jwt = getJWT()
// 4. Configure the session
let session = ConnectSDK.configureAuth(
jwt: jwt, // JWT returned by backend, REQUIRED.
environment: .sandbox, // Environment you want to use (OPTIONAL, defaults to .production)
theme: .dark, // Appearance. Options: .light, .dark and .system (OPTIONAL, defaults to .system)
callbacks: AuthCallbacks( // Listen for events. OPTIONAL.
onClose: { print("Closed") },
onError: { error in print("Error: \(error.message)") },
onDeposit: { deposit in print("Deposit: \(deposit.success ? "successful" : "failed")") }
)
)
// 4. Present the SDK by calling the .present method with the ViewController you want to use.
if let rootVC = UIApplication.shared.windows.first?.rootViewController {
session.present(from: rootVC)
}
}
func getJWT() -> String {
// Make a backend call to retrieve the JWT.
return "jwt-token"
}
}Android
Github links
Requirements
- Android 5.0+ (API 21)
- Kotlin 1.9+
- Android Studio Hedgehog (2023.1.1) or later
Installation via Gradle
- In your app's build.gradle.kts, add the SDK dependency:
dependencies { implementation("com.github.connect-by-zerohash:connect-android:1.0.1") } - Sync your Gradle project.
- Confirm that connect-sdk appears in your project's External Libraries.
Integration
Follow these steps:
- Create an Activity or Fragment in your application that will trigger the Connect flow
- Import the SDK
- When clicking a button or other UI element, start the flow:
-
Get a JWT from a backend API
-
Configure the SDK appearance, environment, and callbacks you want to use
-
Callbacks will return the same data described in the front-end callbacks documentation
-
Call the present method passing your current Activity
-
Example
Represented in our code recipe:
import androidx.appcompat.app.AppCompatActivity
import xyz.connect.sdk.ConnectSDK
import xyz.connect.sdk.ConnectError
import xyz.connect.sdk.Environment
import xyz.connect.sdk.GenericEvent
import xyz.connect.sdk.Theme
import xyz.connect.sdk.auth.AuthCallbacks
import xyz.connect.sdk.auth.DepositEvent
class MainActivity : AppCompatActivity() {
fun startConnect() {
// 1. Get a JWT from your backend
val jwt = getJWT()
// 2. Configure the session
val session = ConnectSDK.configureAuth(
jwt = jwt, // JWT returned by backend, REQUIRED
environment = Environment.SANDBOX, // Environment (optional, defaults to PRODUCTION)
theme = Theme.DARK, // Appearance: LIGHT, DARK, SYSTEM (optional, defaults to SYSTEM)
callbacks = object : AuthCallbacks {
override fun onClose() {
println("Closed")
}
override fun onError(error: ConnectError) {
println("Error: ${error.message}")
}
override fun onEvent(event: GenericEvent) {
println("Event: ${event.type}")
}
override fun onDeposit(event: DepositEvent) {
println("Deposit: ${if (event.success) "successful" else "failed"}")
}
}
)
// 3. Present the SDK from the current Activity
session.present(this)
}
private fun getJWT(): String {
// Make a backend call to retrieve the JWT
return "jwt-token"
}
}