|
| 1 | +# LaunchDarkly React Native SDK - FDv2 Example App |
| 2 | + |
| 3 | +This is a minimal example app that demonstrates the experimental FDv2 data system |
| 4 | +for the React Native SDK. |
| 5 | + |
| 6 | +> **Note:** FDv2 support is `@internal` and experimental. It is not ready for |
| 7 | +> production use and may change or be removed without notice. |
| 8 | +
|
| 9 | +## Features Demonstrated |
| 10 | + |
| 11 | +- SDK initialization with the `dataSystem` option (FDv2 protocol) |
| 12 | +- Connection mode switching for all FDv2 modes: |
| 13 | + - **Streaming** - real-time flag updates with polling fallback |
| 14 | + - **Polling** - periodic polling only |
| 15 | + - **Offline** - cached flags only, no network |
| 16 | + - **One-Shot** - initialize then stop (no persistent synchronizer) |
| 17 | + - **Background** - low-frequency polling for background state |
| 18 | + - **Automatic** - clear the override and use automatic mode selection |
| 19 | +- Context identification |
| 20 | +- Boolean flag evaluation |
| 21 | + |
| 22 | +## Quickstart |
| 23 | + |
| 24 | +1. At the js-core repo root, install dependencies and build: |
| 25 | + |
| 26 | +```shell |
| 27 | +yarn && yarn build |
| 28 | +``` |
| 29 | + |
| 30 | +2. Create an `.env` file in this directory (`example-fdv2/`) with your mobile key: |
| 31 | + |
| 32 | +```shell |
| 33 | +LAUNCHDARKLY_MOBILE_KEY=mob-your-mobile-key-here |
| 34 | +``` |
| 35 | + |
| 36 | +3. Update the flag key in `src/welcome.tsx` if needed (defaults to `sample-feature`). |
| 37 | + |
| 38 | +4. Run the app: |
| 39 | + |
| 40 | +```shell |
| 41 | +# iOS |
| 42 | +yarn ios |
| 43 | + |
| 44 | +# Android |
| 45 | +yarn android |
| 46 | +``` |
| 47 | + |
| 48 | +> **Note:** You may need to run `npx expo prebuild` before the first iOS or |
| 49 | +> Android build. |
| 50 | +
|
| 51 | +## Caveats |
| 52 | + |
| 53 | +- **Network-based automatic mode switching** is not yet implemented. The wiring |
| 54 | + is in place, but `RNStateDetector` does not yet emit network state changes. |
| 55 | + Lifecycle-based switching (foreground/background) works. |
| 56 | +- The `dataSystem` option and `setConnectionMode()` are marked `@internal` and |
| 57 | + require `@ts-ignore` to use from TypeScript. |
0 commit comments