# CrossIndie iOS SDK (Swift)

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

Swift Package Manager: in Xcode, File > Add Package Dependencies, enter `https://github.com/Cross-Indie/sdks` and add the CrossIndie library. The exact package URL / product name and minimum iOS version are in the README: https://github.com/Cross-Indie/sdks/tree/main/ios

## Usage (SwiftUI)

```swift
import CrossIndie

CrossIndieBanner(appId: "YOUR_APP_ID")
```

## Usage (UIKit)

```swift
import CrossIndie

let banner = CrossIndieBannerView(appId: "YOUR_APP_ID")
view.addSubview(banner)
```

Check the README for every option (category, format, callbacks) and layout notes.

## Pitfalls

- Use category `mobile_app` for apps and `game` for games.
- The bundle id is sent automatically so the dashboard can confirm the SDK runs inside your store app.
- Impressions count only while the banner is at least 50% on screen with the app active for 1.5 seconds.
- Clicks open Safari and are reported once per ad.
