Mobile SDK
Mobile SDK
Build your own authenticator app or embed AffirmID into your existing mobile application.
Available Platforms
iOS
v3.2.0 • iOS 14.0+
pod 'AffirmID', '~> 3.2'CocoaPods / Swift Package Manager
Android
v3.1.0 • API 23+ (Android 6.0)
implementation "com.affirmid:affirmid-android:3.1.0"Gradle
React Native
v2.5.0 • RN 0.70+
npm install @affirmid/react-nativenpm / yarn
Flutter
v2.3.0 • Flutter 3.0+
flutter pub add affirmidpub.dev
SDK Features
Push Notifications
Receive and respond to authentication requests via push.
Device Registration
Securely register devices with hardware-backed keys.
Biometric Auth
Integrate Face ID, Touch ID, and fingerprint verification.
TOTP Generation
Generate time-based codes when offline.
iOS Quick Start
1. Install the SDK
# CocoaPods
pod 'AffirmID', '~> 3.2'# Swift Package Manager
https://github.com/affirmid/affirmid-ios2. Initialize the SDK
import AffirmID
// In your AppDelegate or App init
@main
struct MyApp: App {
init() {
AffirmID.configure(
clientId: "your_client_id",
environment: .production // or .sandbox for testing
)
}
}3. Register Push Notifications
import UserNotifications
import AffirmID
// Request permission
UNUserNotificationCenter.current().requestAuthorization(
options: [.alert, .badge, .sound]
) { granted, error in
guard granted else { return }
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
// Forward device token to AffirmID
func application(
_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
) {
AffirmID.shared.registerPushToken(deviceToken)
}4. Handle Authentication Requests
// Listen for incoming auth requests
AffirmID.shared.onAuthRequest = { request in
// Show approval UI
let alert = UIAlertController(
title: "Login Request",
message: "\(request.application) is requesting access",
preferredStyle: .alert
)
alert.addAction(UIAlertAction(title: "Deny", style: .destructive) { _ in
AffirmID.shared.respond(to: request, decision: .denied)
})
alert.addAction(UIAlertAction(title: "Approve", style: .default) { _ in
// Optionally require biometric
AffirmID.shared.respond(
to: request,
decision: .approved,
requireBiometric: true
)
})
present(alert, animated: true)
}Android Quick Start
1. Add Dependencies
// build.gradle (app)
dependencies {
implementation "com.affirmid:affirmid-android:3.1.0"
implementation "com.google.firebase:firebase-messaging:23.0.0"
}2. Initialize the SDK
// Application class
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
AffirmID.initialize(
context = this,
clientId = "your_client_id",
environment = Environment.PRODUCTION
)
}
}3. Handle FCM Messages
class MyFirebaseService : FirebaseMessagingService() {
override fun onNewToken(token: String) {
AffirmID.instance.registerPushToken(token)
}
override fun onMessageReceived(message: RemoteMessage) {
if (AffirmID.instance.isAffirmIDMessage(message)) {
AffirmID.instance.handleMessage(message)
}
}
}TOTP Code Generation
Generate time-based codes locally when users are offline or push notifications aren't available.
iOS
// Get current TOTP code
let code = AffirmID.shared
.generateTOTP()
// code.value = "123456"
// code.remainingSeconds = 15
// Observe code changes
AffirmID.shared.observeTOTP { code in
self.codeLabel.text = code.value
self.progressView.progress =
Float(code.remainingSeconds) / 30.0
}Android
// Get current TOTP code
val code = AffirmID.instance
.generateTOTP()
// code.value = "123456"
// code.remainingSeconds = 15
// Observe code changes
AffirmID.instance.observeTOTP()
.collect { code ->
codeText.text = code.value
progressBar.progress =
code.remainingSeconds
}Configuration Options
| Option | Default | Description |
|---|---|---|
| clientId | Required | Your AffirmID client identifier |
| environment | .production | .production or .sandbox |
| biometricPolicy | .deviceDefault | When to prompt for biometric |
| notificationStyle | .banner | How to display push notifications |
| logLevel | .error | Logging verbosity for debugging |
Resources
Need Help?
Check out our sample apps or reach out to our developer support team.