React Native and Expo
Show the chat as a screen of your React Native or Expo app, with an unread badge.
SupportScreen shows your install's own /embed page in a web view. The same page is used on
the web, so the app gets every change to the chat without a release of its own.
Before you start
- React 19, React Native 0.79 or later, and
react-native-webview13.12 or later. - A source for the app, such as
customer_app. See Add a source. - For logged-in users, identity set up in Settings → Identity. See Know your users.
Add the screen
-
Install the package and the web view:
Terminal npx expo install react-native-webview npm install @helpwren/react-native -
Render
SupportScreenas a screen of your navigator:support.tsx import { SupportScreen } from "@helpwren/react-native"; export function Support({ route, navigation }) { return ( <SupportScreen baseUrl="https://support.example.com" source="customer_app" token={() => auth.getAccessToken()} context={{ appVersion: "3.2.0", screen: route.params?.from }} conversationId={route.params?.conversationId} onUnread={setBadge} onClose={() => navigation.goBack()} /> ); } -
Add the permissions the chat needs to send photos:
NSCameraUsageDescription,NSPhotoLibraryUsageDescriptionandNSMicrophoneUsageDescriptionon iOS (in Expo, underios.infoPlist), and theCAMERApermission on Android.
Every prop is listed in the package reference.
A token given as a function is fetched again once if it has expired. An inline function or
context object does not resend anything on each render; to switch users without logging out,
give the screen a new key.
Show a badge outside the screen
Call getUnreadCount when the app comes to the front:
import { getUnreadCount } from "@helpwren/react-native";
const result = await getUnreadCount({
baseUrl: "https://support.example.com",
token: await auth.getAccessToken(),
});
if (result.ok) setBadge(result.count);It needs no Helpwren session: the install checks the token the same way the chat does.
Links
Only the install's own pages load in the web view. Any other link, such as one in a message, opens in the system browser.
Add a source
An install accepts conversations only from the sources it knows, and starts with web alone.
There is no settings page for sources yet: add one in the Supabase SQL editor, listing every
source the install should accept:
insert into public.settings (key, value)
values ('sources', '["web", "customer_app"]')
on conflict (key) do update set value = excluded.value;Warning
SupportScreen's source must be one of these, or the app cannot start a conversation or
register for push.