Alphyn Sdk Class
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:)- it cannot be deferred. - Throws:
AlphynSDKError.backgroundTaskRegistrationFailedif registration fails.
initialize(interval:debugHash:vmScannerConfig:)
- Signature:
static func initialize(interval: TimeInterval = 45, debugHash: String? = nil, vmScannerConfig: VMScannerConfig = VMScannerConfig()) async throws - Description: Initializes the Alphyn SDK. This method is
async- call it 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- setappUsesMonoRuntime: truefor Unity Mono hosts).
- Throws:
AlphynSDKError.invalidIntervalif the interval is invalid. Calling it again after a successful initialization emits aninitFailedevent and returns.
initializeSync(interval:debugHash:) / registerSync()
- Description: Synchronous wrappers for hosts that cannot use Swift concurrency (Obj-C selectors:
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 |
Protected Assets
Section titled “Protected Assets”loadProtectedAsset(atRelativePath:) / loadAsset(atRelativePath:)
- Signature:
static func loadProtectedAsset(atRelativePath relativePath: String) throws -> Data - Description: Loads an Alphyn-encrypted asset bundled with your app and returns the decrypted bytes. Swift-only overloads with
named:withExtension:subdirectory:are also available.
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.