> For the complete documentation index, see [llms.txt](https://docs.tiun.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tiun.io/sdk/other-platforms/webview.md).

# Native apps with a WebView

This page covers native apps that host **your own web app** in a WebView — a Swift or Kotlin shell around a site you already have.

{% hint style="info" %}
**Building with React Native?** This isn't the page you want. React Native has its own SDK — start at [React Native SDK / Installation](/sdk/react-native-sdk/installation.md).
{% endhint %}

***

## How it works

If your app is a native shell around your own web app, the tiun SDK runs **inside** the WebView the same way it runs in any browser. The native shell does not call the SDK directly — it loads your web app in a `WKWebView` (iOS) or `WebView` (Android) and lets the JS SDK handle checkout, login, and paywall events.

For entitlement checks that need to flow back to native code, expose a small JS bridge that returns a verification token from `getUserVerificationToken()`.

```javascript
import { tiun } from '@tiun/sdk';

tiun.init({
  snippetId: window.TIUN_SNIPPET_ID,
  language: 'en', // 'en' | 'de' | 'fr'
});

window.getTiunVerification = async () => {
  const token = await tiun.getUserVerificationToken();
  return JSON.stringify({ token });
};
```

The native host then calls `getTiunVerification()` via its JS bridge — `evaluateJavascript` on Android, `WKWebView.evaluateJavaScript` on iOS — and forwards the token to its own backend, which verifies it server-side. See [server-side subscription verification](/guides/subscriptions/verify-server-side.md) for the verification round-trip.

### Injecting the snippet ID from the native host

The native shell should inject `window.TIUN_SNIPPET_ID` before page load (via `WKUserScript` on iOS, or `addJavascriptInterface` / `evaluateJavascript` on Android) so the same JS bundle works across environments without hardcoded IDs.

### Lifecycle

* If the native host swaps the WebView's URL (full reload), the page tears down automatically — no `destroy()` needed.
* If the native host swaps DOM content **without** reload, call `tiun.destroy()` before loading new content so listeners and runtime config are cleaned up.

See [Lifecycle and `destroy()`](/sdk/web-sdk/initialization.md#lifecycle-and-destroy) for the full matrix.

***

## Other native SDKs (roadmap)

First-class SDKs for Swift (iOS), Kotlin (Android), and Flutter are on the roadmap.

{% hint style="info" %}
For updates, join the [Discord](https://discord.gg/NCggN2ExZ9) or reach out to <support@tiun.io>.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.tiun.io/sdk/other-platforms/webview.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
