Api Reference
API Reference
Section titled “API Reference”AlphynSDK Class
Section titled “AlphynSDK Class”Main SDK class providing core functionality.
All methods are static.
Lifecycle
Section titled “Lifecycle”register()
- Signature:
static func register() throws - Description: Registers the SDK’s background tasks with iOS (
BGTaskScheduler). Must be called synchronously inapplication(_:didFinishLaunchingWithOptions:). - Throws:
AlphynSDKError.backgroundTaskRegistrationFailed.
initialize(interval:debugHash:vmScannerConfig:)
- Signature:
static func initialize(interval: TimeInterval = 45, debugHash: String? = nil, vmScannerConfig: VMScannerConfig = VMScannerConfig()) async throws - Description: Initializes the Alphyn SDK.
async- call withtry await(e.g. inside aTask). - Parameters:
interval: The interval in seconds for background security scans. Must be greater than 8 seconds (default is 45 seconds).debugHash: Development-only hash from the Alphyn Portal. Never ship it in production builds.vmScannerConfig: Runtime hints for the VM scanner (appUsesJSContext,appUsesMonoRuntime).
- Throws:
AlphynSDKError.invalidIntervalif the interval is invalid. Calling it again after a successful initialization emits aninitFailedevent and returns.
initializeSync(interval:debugHash:) / registerSync() - synchronous wrappers for Obj-C hosts (initializeSyncWithInterval:debugHash:error:, registerSyncAndReturnError:).
setInterval(_ interval: TimeInterval)
- Signature:
static func setInterval(_ interval: TimeInterval) throws - Description: Updates the scan interval in seconds after initialization (must be greater than 8).
- Throws:
AlphynSDKError.notInitialized,AlphynSDKError.invalidInterval.
isInitialized()
- Returns:
Bool- true if initialized, false otherwise. - Thread: Thread-safe
Listeners
Section titled “Listeners”addSecurityListener(_ listener: AlphynSecurityListener) / removeSecurityListener(_ listener: AlphynSecurityListener)
- Description: Adds/removes a security event listener (held weakly; callbacks are delivered on the main thread).
- Thread: Thread-safe
Scan & Device Information
Section titled “Scan & Device Information”All getters are throws and fail with AlphynSDKError.notInitialized before initialization.
| Method | Returns | Description |
|---|---|---|
getScanResult() | String | Latest scan summary (empty string if no scan yet) |
getAllScanResults(startDate: Date? = nil, endDate: Date? = nil) | [String] | Historical scan results (JSON strings), optionally date-filtered |
getAppHash() | String | The app’s integrity hash |
getDeviceId() | String | Persistent unique device identifier |
getLastScanDate() | String | ISO 8601 timestamp of the last scan (empty if never) |
getAllRiskFactors() | [String] | All detected risk factors (["DEVICE_CLEAN"] when clean) |
getRejectReasons() | String | Detected rejection reasons |
getModules() | [String] | Active security modules |
loadProtectedAsset(atRelativePath:) / loadAsset(atRelativePath:) | Data | Decrypts and returns an Alphyn-encrypted bundled asset |
Action Verification
Section titled “Action Verification”High-risk actions are verified with signAction, which signs the transaction with a
hardware-backed key belonging to an enrolled user and returns a short-lived token your backend
validates server-side. See MFA Transaction Signing for the three-call flow, and
MFA on iOS for the signatures.
Errors
Section titled “Errors”AlphynSDKError cases: notInitialized, invalidInterval(message:value:), paymentRequired(message:), backgroundTaskRegistrationFailed(message:), generic(message:), unknown.
AlphynSecurityListener Protocol
Section titled “AlphynSecurityListener Protocol”Protocol for receiving security events from the SDK.
Methods
Section titled “Methods”onSuccess(result: AlphynCallbackResult)
- Description: Called when any operation completes successfully.
- Parameters:
result- Details about the successful operation. - Thread: Main thread
onFailure(result: AlphynCallbackResult)
- Description: Called when any operation fails.
- Parameters:
result- Details about the failed operation and error information. - Thread: Main thread
onThreatDetected(result: AlphynCallbackResult)
- Description: Called when a security threat is detected.
- Parameters:
result- Details about the detected threat. - Thread: Main thread
AlphynCallbackResult Class
Section titled “AlphynCallbackResult Class”Contains detailed information about SDK operations and events.
AlphynCallbackOperationType
initialization- SDK initialization operationssecurityScan- Security scanning operationsscanResponse- Scan result operationsnetwork- Network-related operationsstorage- Secure storage operationscallback- Callback system operations
AlphynCallbackOperationResult
success- Operation completed successfullyfailure- Operation failedthreatDetected- Security threat identified
Properties
Section titled “Properties”operationType: AlphynCallbackOperationType
- Description: Type of operation that triggered this result.
operationResult: AlphynCallbackOperationResult
- Description: Result status of the operation.
originalEventType: AlphynEventType
- Description: Original event type from the SDK.
message: String
- Description: Human-readable message describing the event.
details: String?
- Description: Additional details about the event.
Methods
Section titled “Methods”getScanResult() -> AlphynScanResult
- Description: Returns the scan result enum (meaningful only for scan-response events).
Convenience Properties
Section titled “Convenience Properties”isInitialization: Bool - Returns true if this is an initialization event
isSecurityScan: Bool - Returns true if this is a security scan event
isScanResponse: Bool - Returns true if this is a scan response event
isNetwork: Bool - Returns true if this is a network event
isStorage: Bool - Returns true if this is a storage event
isCallback: Bool - Returns true if this is a callback event
isSuccess: Bool - Returns true if the operation was successful
isFailure: Bool - Returns true if the operation failed
isThreatDetected: Bool - Returns true if a threat was detected
AlphynScanResult Enum
Section titled “AlphynScanResult Enum”Enumeration of possible security scan results.
Values
Section titled “Values”trusted - Application passed all security checks
flagged - Application has potential security concerns
untrusted - Application failed critical security checks
unknown - Scan result unclear or invalid
initializationError - SDK initialization failed
Properties
Section titled “Properties”displayName: String
- Description: Human-readable display name.
emoji: String
- Description: Emoji representation for UI display.
isThreat: Bool
- Description: True if result indicates a security threat.
isCriticalThreat: Bool
- Description: True if result indicates a critical threat.
Static Methods
Section titled “Static Methods”fromString(_ value: String?)
- Description: Parses a string value from the backend (e.g., “TRUSTED”, “FLAGGED”) into an
AlphynScanResultenum case. - Parameters:
value- The string representation of the scan result. - Returns:
AlphynScanResult- The corresponding enum value, or.unknownif the string is not recognized or is empty. - Thread: Thread-safe
AlphynEventType Enum
Section titled “AlphynEventType Enum”Enumeration of all possible SDK events.
Initialization Events
Section titled “Initialization Events”initComplete- SDK initialization completed successfullyinitFailed- SDK initialization failedfirstInit- First-time initialization
Security Events
Section titled “Security Events”threatDetected- Security threat identifiedsecureDevice- Device verified as secureinvalidDateOrTime- Device date/time is invalidscanSuccess- Security scan completed successfullyscanResponse- Scan results are availablescanFailed- Security scan failedriskFactorDetected- A risk factor was detected during a scan
Network Events
Section titled “Network Events”networkInit- Network initializationnetworkMtls- Mutual TLS connection establishedjwtAuthSuccess- JWT authentication successfulnetworkError- Network connectivity errorauthFailed- Authentication failedrequestFailed- API request failed
Storage Events
Section titled “Storage Events”keystoreSuccess- Keystore operation successfulkeystoreFailed- Keystore operation failedkeyExchangeSuccess- Key exchange completedkeysFoundStorage- Existing keys found in storagekeysCreatedNew- New keys created
Callback Events
Section titled “Callback Events”callbackSuccess- Callback operation successfulcallbackFailed- Callback operation failed