# Rewards Hub

> Open your players' rewards page inside your app.

Source: https://docs.onari.xyz/docs/rewards-hub

The Rewards Hub is a mobile web page, branded with your logo and colour, where a player sees their campaigns, progress, voucher codes and trivia. You open it inside your app; there's no extra sign-in.

## 1. Ask for a link from your server

When a signed-in customer opens Rewards, your server calls:

```bash
curl https://api.onari.xyz/v1/hub/sessions \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "player_id": "user_8a21" }'
```

```json
{
  "url": "https://hub.onari.xyz/your-workspace?session=eyJvcmci…",
  "expires_at": "2026-10-20T10:14:40.000Z",
  "expires_in": 3600
}
```

The link works for **one hour**. Make a new one each time the customer opens Rewards; never cache it, share it, or put it in a push notification. See [`POST /v1/hub/sessions`](/docs/api/hub-sessions).

To open a section directly, add `path`: `"/me"` (their rewards and codes), `"/trivia"`, or `"/campaigns/<campaign id>"`.

## 2. Open it in a WebView

<Tabs items={["iOS", "Android", "React Native", "Web"]}>
<Tab value="iOS">

```swift
import WebKit

let web = WKWebView(frame: .zero, configuration: WKWebViewConfiguration())
web.load(URLRequest(url: URL(string: hubURL)!))
```

</Tab>
<Tab value="Android">

```kotlin
val web = WebView(context)
web.settings.javaScriptEnabled = true
web.settings.domStorageEnabled = true
CookieManager.getInstance().setAcceptCookie(true)
web.loadUrl(hubUrl)
```

</Tab>
<Tab value="React Native">

```tsx
import { WebView } from "react-native-webview";

<WebView source={{ uri: hubUrl }} sharedCookiesEnabled />;
```

</Tab>
<Tab value="Web">

Open the link in a new tab or the same window. Don't put it in an `<iframe>`: some browsers block the cookie the Hub uses inside iframes.

</Tab>
</Tabs>

The Hub keeps the session in a cookie for its own address and removes the token from the URL straight away. When the hour is up, the player sees a short "open it again from the app" page.

## Design

Your team sets the logo, brand colour, light or dark look and which sections show in **Dashboard → Rewards Hub**, and can open it as a test player with **Try your Hub**. Changes appear the next time a player opens the Hub.

## What players see

- **Home:** the campaign they're closest to winning, today's trivia, other campaigns, and codes ready to use.
- **Trivia:** quizzes your team runs, timed on Onari's servers so answers can't be looked up or replayed.
- **Me:** every reward they've won, with copyable voucher codes, and their history.

The Hub refreshes when the player comes back to it and every 30 seconds, so progress from a new order shows up without reloading.
