Skip to content

Api Reference

Main SDK class providing core functionality.

All methods are static.

register()

  • Signature: static func register() throws
  • Description: Registers the SDK’s background tasks with iOS (BGTaskScheduler). Must be called synchronously in application(_: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 with try await (e.g. inside a Task).
  • 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.invalidInterval if the interval is invalid. Calling it again after a successful initialization emits an initFailed event 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

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

All getters are throws and fail with AlphynSDKError.notInitialized before initialization.

MethodReturnsDescription
getScanResult()StringLatest 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()StringThe app’s integrity hash
getDeviceId()StringPersistent unique device identifier
getLastScanDate()StringISO 8601 timestamp of the last scan (empty if never)
getAllRiskFactors()[String]All detected risk factors (["DEVICE_CLEAN"] when clean)
getRejectReasons()StringDetected rejection reasons
getModules()[String]Active security modules
loadProtectedAsset(atRelativePath:) / loadAsset(atRelativePath:)DataDecrypts and returns an Alphyn-encrypted bundled asset

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.

AlphynSDKError cases: notInitialized, invalidInterval(message:value:), paymentRequired(message:), backgroundTaskRegistrationFailed(message:), generic(message:), unknown.

Protocol for receiving security events from the SDK.

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

Contains detailed information about SDK operations and events.

AlphynCallbackOperationType

  • initialization - SDK initialization operations
  • securityScan - Security scanning operations
  • scanResponse - Scan result operations
  • network - Network-related operations
  • storage - Secure storage operations
  • callback - Callback system operations

AlphynCallbackOperationResult

  • success - Operation completed successfully
  • failure - Operation failed
  • threatDetected - Security threat identified

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.

getScanResult() -> AlphynScanResult

  • Description: Returns the scan result enum (meaningful only for scan-response events).

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

Enumeration of possible security scan results.

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

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.

fromString(_ value: String?)

  • Description: Parses a string value from the backend (e.g., “TRUSTED”, “FLAGGED”) into an AlphynScanResult enum case.
  • Parameters: value - The string representation of the scan result.
  • Returns: AlphynScanResult - The corresponding enum value, or .unknown if the string is not recognized or is empty.
  • Thread: Thread-safe

Enumeration of all possible SDK events.

  • initComplete - SDK initialization completed successfully
  • initFailed - SDK initialization failed
  • firstInit - First-time initialization
  • threatDetected - Security threat identified
  • secureDevice - Device verified as secure
  • invalidDateOrTime - Device date/time is invalid
  • scanSuccess - Security scan completed successfully
  • scanResponse - Scan results are available
  • scanFailed - Security scan failed
  • riskFactorDetected - A risk factor was detected during a scan
  • networkInit - Network initialization
  • networkMtls - Mutual TLS connection established
  • jwtAuthSuccess - JWT authentication successful
  • networkError - Network connectivity error
  • authFailed - Authentication failed
  • requestFailed - API request failed
  • keystoreSuccess - Keystore operation successful
  • keystoreFailed - Keystore operation failed
  • keyExchangeSuccess - Key exchange completed
  • keysFoundStorage - Existing keys found in storage
  • keysCreatedNew - New keys created
  • callbackSuccess - Callback operation successful
  • callbackFailed - Callback operation failed