Skip to main content
This guide covers how to build a full parental control application using Phosra’s mobile SDKs. It walks through the complete lifecycle from family setup to on-device enforcement, covering both iOS and Android.

Architecture Overview

A Phosra-powered parental control system has four components:
Data flow:
  1. Parent creates a family and child profile via the dashboard or API
  2. Parent creates and activates a policy with age-appropriate rules
  3. Parent registers the child’s device (iOS or Android)
  4. The device SDK fetches the compiled policy from the API
  5. The enforcement engine applies rules using native OS APIs
  6. The device reports enforcement status and usage data back to Phosra
  7. When the parent updates rules, a push notification triggers immediate re-sync

Registration Flow

Policy Lifecycle

A policy goes through these stages:

1. Create a Draft Policy

2. Generate Age-Appropriate Rules

3. Activate the Policy

4. Device Fetches the Compiled Policy

The device SDK calls GET /device/policy and receives a CompiledPolicy with all rules translated into an enforceable format (content filters, screen time, web filters, etc.).

5. On-Device Enforcement

The enforcement engine maps each policy section to native OS APIs and applies the restrictions.

6. Report Back

The device submits an enforcement status report listing per-category results (enforced, partial, failed, unsupported).

Platform Comparison

Handling Age Transitions

When a child crosses an age bracket boundary (e.g., turning 13), the parent may want to adjust their policy. Phosra makes this straightforward:

Detecting the transition

The Phosra API knows each child’s birth date and automatically computes the age group. There is no child.* webhook event — the census fires exactly five events, none of them age-related (see Webhook events). Detect the boundary crossing in your app instead: read age_group from GET /children/{childId} on your regular policy-refresh cycle (or compute it locally from the birth date you already hold) and compare it to the last value you stored:

Regenerate Rules

Call generateFromAge to update rules for the new age group:

Gradual Relaxation

For a smoother transition, adjust specific rules rather than regenerating everything:

Multi-Device Setup

A single child can have multiple devices registered, and each receives the same compiled policy.

Register Multiple Devices

Each device:
  • Has its own unique API key (stored in that device’s secure storage)
  • Fetches the same compiled policy
  • Reports enforcement status independently
  • Receives push notifications independently

Cross-Device Screen Time

Screen time is tracked per-device. To enforce a combined limit across devices, use the Phosra API to aggregate:

List Devices for a Child

Offline Enforcement

Both SDKs cache the most recent compiled policy on-device, enabling enforcement even without network connectivity.

How It Works

  1. When a policy is fetched, the SDK stores it locally:
    • iOS: UserDefaults or app container (policy data is non-sensitive)
    • Android: SharedPreferences
  2. On app launch or device reboot, the enforcement engine loads the cached policy and re-applies it immediately.
  3. When network returns, the SDK syncs with the API and applies any updates.

Cache Strategy

Considerations

  • Cached policies remain enforced indefinitely until a newer version is fetched
  • Screen time counters persist across reboots (stored locally)
  • If a parent revokes a device, the revocation takes effect on the next successful API call
  • For maximum reliability, use APNs (iOS) or FCM (Android) to push policy updates immediately

Security Considerations

API Key Storage

The device API key is:
  • Generated server-side as 32 random bytes (hex-encoded, 64 characters)
  • Returned exactly once during device registration
  • Stored as a SHA-256 hash on the server; the plaintext is never stored server-side
  • Used as X-Device-Key header for all device-authenticated API calls

Tamper Detection

Prevent the child from bypassing enforcement:

iOS

  • FamilyControls runs at the OS level; apps cannot bypass it
  • ManagedSettings persists across app deletion and reinstall
  • DeviceActivity monitoring continues even if the app is force-quit
  • Shield UI is rendered by the OS, not the app

Android

  • Device Admin prevents app uninstall without parent PIN
  • VPN service runs as foreground service (persistent)
  • AccessibilityService restarts automatically if killed
  • Boot receiver re-applies enforcement after reboot
  • Overlay blocks interaction with restricted apps

Communication Security

  • All API communication uses HTTPS (TLS 1.2+)
  • Device keys are transmitted only once (during registration)
  • Conditional fetching (since_version) minimizes data transfer
  • Push notifications contain only the event type and version number, not policy data