← Back to guides

iOS SDK (Swift)

Protect signup and login in iOS apps with the AbuseGraph Swift package — session → check, fail-open.

Install the iOS SDK

// Xcode → File → Add Package Dependencies → AbuseGraph iOS package
// Product: AbuseGraph

import AbuseGraph

let client = AbuseGraphClient(
  config: AbuseGraphConfig(
    apiKey: ProcessInfo.processInfo.environment["ABUSEGRAPH_SECRET_KEY"] ?? "sk_test_…",
    site: "yourdomain.com"
  )
)

Proxy sk_ keys through your backend. App Attest goes in DeviceCollect.attestation.

Keys

Use sk_test_… while integrating. Production sk_live_… belongs on your backend — never in an App Store binary. Pass the DNS-verified site as site / x-abusegraph-site.

Flow

  1. Collect device metadata (AbuseGraphDevice.currentCollect).
  2. sessionThenCheckPOST /api/v1/session then POST /api/v1/check.
  3. Enforce verdict in your app. On failOpen, allow the user.

swift

import AbuseGraph

let client = AbuseGraphClient(
  config: AbuseGraphConfig(
    apiKey: ProcessInfo.processInfo.environment["ABUSEGRAPH_SECRET_KEY"] ?? "sk_test_…",
    site: "yourdomain.com"
  )
)

let result = await client.sessionThenCheck(
  email: email,
  event: .signup
)

if result.failOpen {
  // Network blip — allow
} else if result.verdict == .block {
  // Reject signup
}

App Attest (optional)

swift

let device = AbuseGraphDevice.currentCollect(attestation: attestAssertion)
let result = await client.sessionThenCheck(
  email: email,
  event: .signup,
  device: device
)

Attestation is stored under session probes.attestation.

Events

signup, login, password_reset, email_change.

Package

Source: packages/sdk-ios (Swift Package Manager product AbuseGraph). See also Android and React Native.