# CrossIndie in Capacitor, Ionic and Cordova apps

## 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

There is no separate SDK: a hybrid app is a web page inside a WebView, so the web embed (see https://crossindie.com/docs/llms/web.md) works unchanged. Add it to `index.html`:

```html
<script src="https://api.crossindie.com/embed.js" data-api-base="https://api.crossindie.com" async></script>
<div data-ci-app-id="YOUR_APP_ID" data-ci-category="mobile_app" data-ci-format="mobile"></div>
```

## Single-page frameworks (Ionic Angular / React / Vue)

Load the script once in `index.html` and call `CrossIndie.initSlots("https://api.crossindie.com")` after the slot element mounts (`ngAfterViewInit`, `useEffect`, `onMounted`), or use `CrossIndie.createBanner({ el, appId, category: "mobile_app", format: "mobile", apiBase: "https://api.crossindie.com" })`.

## Pitfalls

- Banner links use `target="_blank"`. Capacitor opens them in the system browser. On Cordova keep `<allow-intent href="https://*/*" />` in `config.xml` (or use cordova-plugin-inappbrowser).
- The WebView origin is `localhost` (`capacitor://localhost`, `https://localhost`, `http://localhost`). If you set Allowed web domains on the app, add `localhost`, or leave the list empty.
- Use category `mobile_app` (or `game` for games).
