# Native Integration

Load `session_url` directly in a native WebView. The widget sends the same
events as the web integration through a native bridge.

| Platform | Event bridge |
| --- | --- |
| iOS `WKWebView` | Provide a handler for the `ReactNativeWebView.postMessage(json)` shim. |
| Android `WebView` | Add a JavaScript interface named `PrivyAndroid`. The widget calls `PrivyAndroid.postMessage(json)`. |

Bridge messages are front-channel notifications for the user interface. They do
not query the backend session status.

The bridge receives JSON in this form:

```json
{
  "type": "privy:success",
  "payload": {
    "session_id": "9f1c2c8a-2d6f-4d60-9ab1-85a5d4aa93d0",
    "exchange_code": "single-use-code",
    "token": "eyJ...",
    "sections": []
  }
}
```

## Trusted-host payload

A native WebView is a trusted host and receives the complete payload. The
payload can contain:

- `exchange_code` for server-to-server exchange.
- `token` with the verified-data JWT.
- `sections` with the shared-data preview.

> Prefer the exchange-code flow. It prevents the token from traveling through
> the front channel. Always verify the JWT on the merchant backend. With the
> Identity package, decrypt `my_identity` on the backend after JWT
> verification.

See [Camera and Permissions](/digital-id/guides/camera-and-permissions) for
the liveness-camera contract.
