iOS Collector
The LightChallenge iOS app collects Apple Health evidence (steps and walking/running distance) and submits it to the backend for verification.
Overview
The iOS collector is a lightweight SwiftUI app that:
- Reads HealthKit data (step count, walking + running distance)
- Packages it as a JSON evidence payload
- Submits it to the
/api/aivm/intakeendpoint - Authenticates via a signed evidence token from the webapp
Requirements
- Xcode 15+
- iOS 17+ device (HealthKit requires a physical device)
- Apple Developer account (free tier works for personal testing)
Setup
1. Open the Project
open mobile/ios/LightChallengeApp/LightChallengeApp.xcodeproj2. Configure Server URL
Edit Sources/Models/Models.swift and set the server URL for your environment:
- UAT (default):
https://uat.lightchallenge.app - Production:
https://app.lightchallenge.app - Local dev: Replace
YOUR_MAC_IPwith your Mac’s LAN IP address
3. Signing
In Xcode:
- Select the project in the navigator
- Go to Signing & Capabilities
- Select your personal team
- Let Xcode manage signing automatically
4. Build and Run
Select your iPhone as the target device and press Cmd+R.
Usage Flow
Full Authenticated Flow (Recommended)
- Open the webapp in a browser and connect your wallet
- Navigate to a challenge’s proof page
- Select “Apple Health” as the evidence source
- Click “Sign & Generate QR” — this signs a one-time token with your wallet
- Scan the QR code with your iPhone camera
- The app opens via deep link with the auth token pre-filled
- Grant HealthKit permissions when prompted
- Tap “Collect Health Data” then “Submit Evidence”
How Authentication Works
The webapp generates an EIP-191 signed message:
lightchallenge-evidence:{challengeId}:{subject}:{expires}This signature is embedded in the deep link URL and sent with the evidence submission. The server recovers the signer and verifies it matches the wallet address.
HealthKit Permissions
The app requests read-only access to:
HKQuantityType(.stepCount)— Daily step countsHKQuantityType(.distanceWalkingRunning)— Walking and running distance
No write permissions are requested. No clinical health records are accessed.
Deep Link Format
lightchallenge://challenge/{id}?subject={wallet}&token={signature}&expires={timestamp}| Parameter | Description |
|---|---|
id | Challenge ID |
subject | Wallet address (0x…) |
token | EIP-191 signature from webapp |
expires | Token expiry timestamp (ms) |
Troubleshooting
| Issue | Solution |
|---|---|
| App won’t install | Trust developer cert: Settings → General → VPN & Device Management |
| Network error on submit | Ensure iPhone and Mac are on same Wi-Fi; check IP in Models.swift |
| HealthKit permission denied | Re-enable in Settings → Health → Data Access |
| ”No auth token” warning | Open the app via QR code from the webapp, not directly |
| Deep link doesn’t open app | Rebuild and reinstall the app to register URL scheme |