For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
SupportDashboard
Getting StartedAPI ReferenceRoadmapBlog
Getting StartedAPI ReferenceRoadmapBlog
  • Getting Started
    • Overview
    • What is Schematic?
    • Concepts
  • Using Schematic
    • Who Uses Schematic
  • Quickstart
    • Quickstart
    • Account Setup
    • Entitling a Feature
    • Tracking Usage
    • Components
    • Identifying Users
    • Setup the SDK
  • Using Feature Flags
    • Overview
    • Flags
    • Features
    • Tracking Feature Usage
    • Company Overrides
    • Feature Types
  • Building Your Catalog
    • Overview
    • Plans
    • Managing Company Plans
    • Configuring the Catalog
    • Add Ons
    • Trials
  • AI Tooling
    • For Developers
  • Setting Up Billing
    • Overview
    • Usage Based Billing Models
    • Seat Based Billing Models
    • Credit burndown
  • Using UI Components
    • Overview
  • Developer Resources
    • Concepts
    • Key Management
    • Environments
    • Entity Relationship Diagram
      • Overview
      • Cross-platform Features
      • React
      • React Native
      • Vue
      • Angular
      • Nextjs
      • Javascript (Client-side)
      • Go
      • Node.js
      • Python
      • C#
      • Java
      • Ruby
  • Production Readiness
    • Availability
    • Observability & Support
    • Security
  • Integrations
    • Segment Integration
    • Clerk Integration
    • WorkOS Integration
    • Salesforce Integration
    • Hubspot Integration
  • Playbooks
    • Overview
    • Creating a metered feature
    • Backfills and usage corrections
    • Rolling out beta functionality with Flags
    • Handling customer exceptions and feature trials
    • Automatically provision customers using Stripe
    • Build a slack webhook
LogoLogo
SupportDashboard
On this page
  • Handling Application Backgrounding
Developer ResourcesSDKs

React Native

Was this page helpful?
Previous

Vue

Next
Built with

Schematic’s React SDK also works for React Native apps. See the React SDK documentation for more details about how to use the React SDK.

Handling Application Backgrounding

When your application is brought back to the foreground, Schematic will automatically reconnect to the WebSocket to resume flag checks and event tracking. This will ensure that your application is always up to date with the latest flag data and event tracking.

However, the SDK implements reconnects with an expontial backoff timer, which may cause a delay before fresh flag values are available. For cases where you need immediate flag updates when returning to the foreground (e.g., after an in-app purchase), you can use one of these methods to re-establish the connection:

  • forceReconnect(): Always closes and re-establishes the WebSocket connection, guaranteeing fresh values
  • reconnectIfNeeded(): Only reconnects if the current connection is unhealthy (more efficient for frequent foreground events)

An example of using these when the application is brought back to the foreground looks like:

1import { useSchematic } from "@schematichq/schematic-react";
2import { useEffect } from "react";
3import { AppState } from "react-native";
4
5const SchematicAppStateHandler = () => {
6 const { client } = useSchematic();
7
8 useEffect(() => {
9 const subscription = AppState.addEventListener("change", (state) => {
10 if (state === "active") {
11 // Use forceReconnect() for guaranteed fresh values
12 client.forceReconnect();
13 // Or use reconnectIfNeeded() to skip if connection is healthy
14 // client.reconnectIfNeeded();
15 }
16 });
17 return () => subscription.remove();
18 }, [client]);
19
20 return null;
21};