adyen/adyen-authentication-ios
The AdyenAuthentication SDK provides reusable, secure, and easy-to-integrate two-factor authentication for sensitive use cases such as banking, issuing, and PSD2 strong customer authentication.
βοΈ Installation
The SDK can be integrated via CocoaPods, Carthage, Swift Package Manager, or manual installation.
CocoaPods
- Add the following line to your
Podfile:
``ruby pod 'AdyenAuthentication' ``
Carthage
Note: Carthage is no longer actively maintained and is not recommended for new projects. Prefer Swift Package Manager if possible.
- Add the following to your
Cartfile:
``text github "adyen/adyen-authentication-ios" ``
- Link the generated framework with your target as described in Carthageβs guide.
Swift Package Manager (Recommended)
- Follow Appleβs guide on Adding Package Dependencies to Your App.
- Use the repository URL:
https://github.com/Adyen/adyen-authentication-ios
Requirements:
- Swift 5.7+
- Xcode 16+
- iOS 14 or later for DeviceCheck
- iOS 16 or later for passkeys.
XCFramework Installation
Dynamic xcFramework
- Drag
XCFramework/Dynamic/AdyenAuthentication.xcframeworkinto the Frameworks, Libraries, and Embedded Content section of your app target. - Choose βCopy items if needed.β
Static xcFramework
- Drag
XCFramework/Static/AdyenAuthentication.xcframeworkinto the Frameworks, Libraries, and Embedded Content section. - Ensure the framework is not embedded.
π± Supported App Targets
| Authentication Method | iOS App | App Extension | Documentation | | :--- | :---: | :---: | :--- | | DeviceCheck | β Supported | β Not Supported | App Attest | | Passkeys | β Supported | β οΈ Conditional | ASAuthorizationController |
For App Extensions, Passkeys require ASAuthorizationControllerPresentationContextProviding.
π Prerequisites
Before using the AdyenAuthentication SDK, configure your Xcode project with the required Apple capabilities.
| Authentication Method | Required Capability | Documentation | |-----------------------|---------------------|---------------| | DeviceCheck | DeviceCheck + App Attest | Preparing to Use the App Attest Service | | Passkeys | Associated Domains | Supporting Passkeys |
DeviceCheck
- Enable App Attest capability in your app target.
- Add the following to your
.entitlementsfile:
``xml <key>com.apple.developer.devicecheck.appattest-environment</key> <string>production</string> ``
Use
productionfor live environments. For sandbox testing, configure appropriately.
Passkeys
- Enable Associated Domains capability.
- Add your domain using the
webcredentialsservice:
`` webcredentials:your-domain.com ``
Ensure your
relyingPartyIdentifierin code matches the associated domain declared here.
π§© Usage
Initialization Options
You can initialize the SDK in one of two mutually exclusive ways:
1. Using DeviceCheck APIs
let configuration = AuthenticationService.Configuration(
localizedRegistrationReason: "Biometric use explanation for registration.",
localizedAuthenticationReason: "Biometric use explanation for authentication.",
appleTeamIdentifier: "YOUR_APPLE_TEAM_ID"
)
let authenticationService = AuthenticationService(configuration: configuration)Ensure the App Attest capability and App Attest entitlement are configured.
2. Using Apple Passkeys
let configuration = AuthenticationService.PassKeyConfiguration(
relyingPartyIdentifier: "your-domain.com",
displayName: "Your App Name",
consecutiveApprovalCancellationsLimit: 3 // Optional: refer AdyenAuthenticationError.consecutiveCancellationOnApproval
)
let authenticationService = AuthenticationService(passKeyConfiguration: configuration)Ensure the Associated Domains capability is enabled and your webcredentials entry matches the relying party domain.
Checking Device Support
do {
let deviceSupportPayload = try authenticationService.checkSupport()
// Send this payload to your backend for validation.
} catch {
print("Device not supported: \(error)") // `AdyenAuthenticationError` if not supported.
}If successful, checkSupport() returns a Base64 URL-encoded payload describing device capabilities.
Registering and Authenticating
Check Registration Status
do {
let isDeviceRegistered = try await authenticationService.isDeviceRegistered(withAuthenticationInput: backendInput) /*The opaque string sdk input*/
} catch error {
// refer: `AdyenAuthenticationError` for the type of errors.
}Register Device
do {
let sdkOutput = try await authenticationService.register(withRegistrationInput: backendInput) /*The opaque string sdk input*/
} catch error {
// refer: `AdyenAuthenticationError` for the type of errors.
}Authenticate User
do {
let sdkOutput = try await authenticationService.authenticate(withAuthenticationInput: backendInput) /*The opaque string sdk input*/
} catch error {
// refer: `AdyenAuthenticationError` for the type of errors.
}π§ Error Handling
Common AuthenticationService.Error cases includes:
.userCancelled// User cancelled authentication.deviceOwnerAuthenticationFailure// Indicates that device owner authentication failed.
For more such errors refer to the source documentation.
π§© Support
If you encounter a bug or have a feature request, open an issue. For other questions, contact Adyen Support.
π See Also
π License
This SDK is available under the Apache License, Version 2.0. See the LICENSE file for details.
Package Metadata
Repository: adyen/adyen-authentication-ios
Default branch: main
README: README.md