device-integritylisted
Install: claude install-skill thienqo/ios-skills
# Device Integrity
Verify that requests to your server originate from genuine Apple devices running legitimate instances of your app. `DCDevice` provides per-device bits for persistent state (e.g., promo redemption), while `DCAppAttestService` provides cryptographic proof of app authenticity using Secure Enclave keys.
**Security Boundary:** App Attest proves client hardware/app integrity; it does not replace user authentication, TLS, authorization, or certificate pinning. Always enforce user authentication after App Attest verification succeeds.
## Contents
- [DCDevice (DeviceCheck)](#dcdevice-devicecheck)
- [DCAppAttestService (App Attest)](#dcappattestservice-app-attest)
- [Key Generation & Attestation Flow](#key-generation--attestation-flow)
- [Assertion Flow](#assertion-flow)
- [Error Handling & Key Lifecycle](#error-handling--key-lifecycle)
- [Common Mistakes](#common-mistakes)
- [Review Checklist](#review-checklist)
- [References](#references)
## DCDevice (DeviceCheck)
`DCDevice` generates ephemeral, single-use tokens sent to your backend, which communicates with Apple to read or update two per-device bits that persist across app reinstallation.
```swift
import DeviceCheck
func generateDeviceToken() async throws -> Data {
guard DCDevice.current.isSupported else {
throw DeviceIntegrityError.deviceCheckUnsupported
}
return try await DCDevice.current.generateToken()
}
```
Treat each token as strictly single-use. Generate a fresh token for every