# CrossIndie React Native / Expo SDK

## Concepts

- **app_id**: the id of your app, shown in the dashboard under My Apps (https://crossindie.com/dashboard/apps). It is public; it goes into your app, game or site code.
- **App API key** (`api_key`): secret, used only for the account API and the MCP server. Never put it in a shipped app, game or web page.
- **api_base**: `https://api.crossindie.com`.
- **category**: `game`, `web_tool`, `saas` or `mobile_app`. Games are shown only to games; web tools and SaaS share a pool.
- Every placed banner is an independent earning slot. An impression only counts after the banner has been visible for at least 1.5 seconds (while the window or app is focused). All credit and anti-fraud checks run on the server.
- New apps may need review before they are served. Check the app status in the dashboard.
- An app is promoted only once it is live on a store. For Google Play and App Store links the package (`play_package`) or numeric id (`appstore_id`) is derived from `target_url`; CrossIndie checks store liveness every 12 hours and shows `store_status` (live, not_found, error, unknown). Web apps do not need a store listing.

## Install

Pure JS/TS, no native modules: works in Expo Go, Expo dev builds and bare React Native. Not on npm yet; vendor it from the SDK repo (`lib/` is prebuilt):

```bash
npx degit Cross-Indie/sdks/react-native vendor/crossindie-react-native
npm install ./vendor/crossindie-react-native
npx expo install expo-application   # optional: lets the SDK send your bundle id
```

The package name is `@crossindie/react-native`.

## Usage

```tsx
import { CrossIndieBanner } from "@crossindie/react-native";

<CrossIndieBanner appId="YOUR_APP_ID" />
```

Props: `appId` (required), `category` ("game" | "web_tool" | "saas" | "mobile_app", default "mobile_app"), `format` ("card" | "rectangle" | "leaderboard" | "mobile" | "text", default "card"), `apiBase` (default `https://api.crossindie.com`), `packageName` (auto from expo-application), `country`, `lang`, `visible` (boolean, default true), `closeable` (default true), `refreshSeconds` (optional rotation, min 30), `style`, `onAdLoaded`, `onNoAd`, `onImpression`, `onClick`, `onError`.

## Pitfalls

- With React Navigation, pass `visible={useIsFocused()}`: stacked screens stay mounted when hidden.
- The component returns null until an ad arrives and on any error.
- Impressions need non-zero size, at least 50% inside the window and the app active, continuously for 1.5 s.
- Clicks open the external browser via `Linking.openURL`.
