Swift SDK for integrating the zerohash Fund product into your iOS app.
The SDK exposes one flow you can present from your app:
- Fund — account funding / pay-to-settle flow
- Account funding flow exposed through a single SDK call
- WebView bridge for JS/native messaging over a hardened
WKWebView - Light, dark, and system theming
- Typed event callbacks
- Sandbox and production environments
- iOS 14+
- Swift 6.0+
- Xcode 15.3+
- In Xcode, select File > Add Package Dependencies...
- Enter the repository URL:
https://github.com/zerohash/zerohash-ios - Select the version rule you want to use (we recommend up to next major)
- Click Add Package
Add ZerohashSDK as a dependency in your Package.swift file:
dependencies: [
.package(url: "https://github.com/zerohash/zerohash-ios", from: "1.0.0")
]Then add ZerohashSDK to your target's dependencies:
targets: [
.target(
name: "YourApp",
dependencies: ["ZerohashSDK"]
)
]import ZerohashSDKBefore presenting the Fund flow, you'll need to obtain a JWT token from your backend. This token authenticates the end user with the zerohash platform.
For detailed instructions on obtaining JWT tokens, please refer to the zerohash documentation.
The Fund app handles account funding and pay-to-settle. Use onFund to
react to deposit events.
import UIKit
import ZerohashSDK
class FundViewController: UIViewController {
private var fundSession: ZerohashFundSession?
@IBAction func startFundTapped(_ sender: UIButton) {
let callbacks = FundCallbacks(
onClose: { print("Fund closed") },
onError: { error in
print("Fund error \(error.code): \(error.message)")
},
onEvent: { event in
print("Fund event: \(event.type)")
},
onFund: { fund in
if fund.success {
print("Deposit processed — status: \(fund.status ?? "unknown")")
} else {
print("Deposit status: \(fund.status ?? "unknown")")
}
}
)
fundSession = ZerohashSDK.configureFund(
jwt: "your-jwt-token",
environment: .production,
theme: .system,
callbacks: callbacks
)
fundSession?.present(from: self)
}
}The main entry point for the SDK.
Configures a Fund session that can be presented later. Returns a
ZerohashFundSession.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
jwt |
String |
— | JWT token authenticating the end user |
environment |
Environment |
.production |
.sandbox or .production |
theme |
Theme |
.system |
.light, .dark, or .system |
callbacks |
FundCallbacks |
empty | Event callbacks for the Fund flow |
Presents the Fund UI modally from the specified view controller.
- Parameter
viewController: UIViewController— the view controller to present from
Cancels the session if it is active.
A boolean indicating whether the session is currently active.
enum Environment {
case sandbox // Certification / testing environment
case production // Live environment
}enum Theme {
case light // Force light theme
case dark // Force dark theme
case system // Follow the device appearance setting
}struct FundCallbacks {
var onClose: (() -> Void)?
var onError: ((ErrorEvent) -> Void)?
var onEvent: ((GenericEvent) -> Void)?
var onFund: ((FundEvent) -> Void)?
}Called when a fund event occurs during the Fund flow.
fund.success // Bool — true when the deposit was processed
fund.status // String? — current deposit status
fund.data // [String: Any] — raw event payload
fund.jsonString // String — raw JSON stringCalled when an error occurs during the flow.
error.code // String — error code
error.message // String — human-readable error message
error.data // [String: Any] — additional error details
error.jsonString // String — raw JSON string
error.timestamp // Date — when the error occurredCalled for generic analytic and lifecycle events during the flow.
event.type // String — event type identifier
event.data // [String: Any] — event payload
event.getString("key") // String?
event.getInt("key") // Int?
event.getBool("key") // Bool?
event.getDouble("key") // Double?
event.getObject("key") // [String: Any]?Called when the session is closed by the user or programmatically via
cancel().
The SDK supports three theme options:
// Light theme
ZerohashSDK.configureFund(jwt: token, theme: .light)
// Dark theme
ZerohashSDK.configureFund(jwt: token, theme: .dark)
// System theme (default) — matches device settings
ZerohashSDK.configureFund(jwt: token, theme: .system).system— Automatically switches between light and dark based on device settings.light— Forces light theme regardless of device settings.dark— Forces dark theme regardless of device settings
The theme applies to the WebView content and the loading indicator.
For additional support or questions about the zerohash platform: