PhosraSDK Swift package provides on-device child safety enforcement for iOS using Apple’s FamilyControls, ManagedSettings, and DeviceActivity frameworks.
Overview
The SDK has a two-layer architecture:- API Client — Communicates with the Phosra API to register devices, fetch compiled policies, submit enforcement reports, and acknowledge policy versions.
- Enforcement Engine — Translates the compiled policy document into native Apple framework calls to enforce content filters, screen time limits, web filtering, purchase controls, and more.
API Client
Handles device registration, policy sync, and reporting via the Phosra REST API.
Enforcement Engine
Maps policy rules to FamilyControls, ManagedSettings, and DeviceActivity calls.
Requirements
Installation
The
PhosraSDK Swift package is in private preview. Contact developers@phosra.com to receive the repository URL and access credentials. Once you have access, add it via Swift Package Manager:Xcode
Quick Start
Device Registration
The registration flow requires parent authentication and produces a device-specific API key:RegisterDeviceRequest includes device metadata and capability declarations:
Policy Sync
Automatic Polling with PolicySyncManager
ThePolicySyncManager handles periodic policy fetching with conditional requests:
Push-Based Sync (APNs)
For immediate policy refresh when a parent modifies rules, handle APNs silent push notifications:Enforcement Engine
Each enforcer handles a specific policy section and maps it to the appropriate Apple framework.Content Filter Enforcer
UsesManagedSettings to control app access based on age ratings and block/allow lists.
Screen Time Enforcer
UsesDeviceActivity to monitor and limit screen time.
Web Filter Enforcer
UsesManagedSettings web content filtering.
Purchase Enforcer
Social Enforcer
Notification Enforcer
Reporting
The SDK submits two types of reports to the Phosra API:Enforcement Status Report
Sent after applying a policy, contains per-category results:Screen Time Report
Aggregated daily usage data:CompiledPolicy Structure
The compiled policy is fetched fromGET /device/policy and contains all enforcement rules organized by section:
Supported Rule Categories
The 45 OCSS rule categories the iOS SDK maps to native framework primitives (of the 123 categories in the OCSS rule registry; the remainder are policy-only or census-enforced and carry no client-side Apple verb):Content Rules
Time Rules
Purchase Rules
Social Rules
Web Rules
Privacy Rules
Monitoring Rules
Engagement Rules
Notification Rules
Legislation-Driven Rules
Compliance Rules
Parental / Legislative Rules
Troubleshooting
ManagedSettingsStore changes not applying
ManagedSettingsStore changes not applying
- Verify FamilyControls authorization status is
.approved ManagedSettingsStorechanges are transactional; create a new store instance if the previous one has stale state- Check the device logs:
log stream --predicate 'subsystem == "com.apple.ManagedSettings"'
DeviceActivity monitoring not starting
DeviceActivity monitoring not starting
- The
DeviceActivityMonitorextension must be a separate target in your Xcode project - Verify the extension’s bundle ID matches the App Group
- Maximum of 20 concurrent
DeviceActivityScheduleinstances per app
Policy fetch returns 304 Not Modified
Policy fetch returns 304 Not Modified
This is expected behavior. When you pass
sinceVersion, the server returns 304 if the policy has not changed. The SDK returns nil in this case — no action is needed.Keychain errors on first launch
Keychain errors on first launch
- Ensure Keychain Sharing capability is enabled if using app extensions
- Use
kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly(the SDK default) for device keys - On simulator, Keychain behavior may differ from physical devices
App Store rejection for FamilyControls usage
App Store rejection for FamilyControls usage
- Provide a detailed description of your child safety use case in App Store Connect
- Include screenshots showing the parent consent flow
- Reference applicable legislation (COPPA, KOSA, etc.) in your review notes
- Ensure your privacy policy covers data collected from child devices