For the complete documentation index, see llms.txt. This page is also available as Markdown.

Mobile and Native

There are two ways to use tiun in a mobile app today: Mobile WebView (supported now) and first-class native SDKs (on the roadmap).


Mobile WebView (available today)

The tiun SDK runs inside a 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().

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 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() for the full matrix.


Native SDKs (roadmap)

First-class native SDKs — Swift (iOS), Kotlin (Android), React Native, and Flutter — are on the roadmap.

Native SDKs are coming soon. For updates, join the Discord or reach out to support@tiun.app.

Last updated

Was this helpful?