# CrossIndie Unreal Engine 5 plugin

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

1. Copy `CrossIndie` from https://github.com/Cross-Indie/sdks (folder `unreal/CrossIndie`) into the project's `Plugins/` directory.
2. Regenerate project files and build. The plugin needs the `HTTP`, `Json` and `JsonUtilities` modules (already declared in its Build.cs).
3. Enable CrossIndie in Edit > Plugins and restart the editor.

## Usage

`UCrossIndieBannerComponent` is an ActorComponent. Properties: `ApiBase` (FString), `AppId` (FString), `Category` (FString, default "game"), `bAutoLoad` (bool). Delegates: `OnAdLoaded(Name, Description, BannerImageUrl, TargetUrl)` and `OnAdFailed(Reason)`. Functions: `LoadAd()`, `HandleClick()`. All are Blueprint-exposed.

```cpp
UCrossIndieBannerComponent* Banner = NewObject<UCrossIndieBannerComponent>(this);
Banner->ApiBase  = TEXT("https://api.crossindie.com");
Banner->AppId    = TEXT("YOUR_APP_ID");
Banner->Category = TEXT("game");
Banner->bAutoLoad = false;
Banner->RegisterComponent();
Banner->OnAdLoaded.AddDynamic(this, &AMyHud::HandleAdLoaded); // UFUNCTION with (const FString&) x4
Banner->LoadAd();
```

## Pitfalls

- The component does not draw anything. Bind `OnAdLoaded`, download `BannerImageUrl` into a texture or brush, and render it in UMG.
- Call `HandleClick()` from your widget's click event; it opens the target URL and reports the click.
- Default `ApiBase` is `http://localhost:8000`. Set it to `https://api.crossindie.com`.
- Impressions accrue only while `FApp::HasFocus()` is true.
- Delegate handlers bound with AddDynamic must be UFUNCTIONs.
