React Native SDK
Install agent44 in a React Native or Expo app: configure it, identify signed-in users with a signature, open the chat and help center, show update prompts and set up push.
AAgent44Updated 9 min read
On this page
- Quick start
- 1. Get your SDK key
- 2. Install the package
- 3. Start the SDK
- 4. Add a chat button
- Tell agent44 who your users are
- Verify your users
- Keep the signature out of backups (recommended with verification)
- Everything you can open
- Update prompts and What's New
- Push notifications (optional)
- Not yet in this version
Add customer support to your React Native app in a few minutes: a chat with your team and AI agent, a help center, "update your app" screens and What's New. You manage all of it from your agent44 dashboard.
Works on iOS and Android, in Expo (including Expo Go) and bare React Native. The package is pure TypeScript: no native module of its own, so there's nothing to link and no pod install beyond what its peer dependencies need.
It's the React Native port of agent44 for Flutter: the same API calls, the same behaviour, the same screens.
The package is @agent44/react-native on npm. Also available for Flutter, iOS and Android.
The full reference, with every option, is the SDK's README on GitHub: harithwick/agent44-react-native.
Quick start#
1. Get your SDK key#
In agent44, open Settings › Apps, pick your app (or Add app) and click Create SDK key. Copy it: it starts with a44_pub_ and is shown only once.
Your app is on both stores? Add it once for iOS and once for Android. You'll get one key for each.
2. Install the package#
With Expo:
npx expo install @agent44/react-native @react-native-async-storage/async-storage react-native-webview react-native-safe-area-contextWith bare React Native:
npm install @agent44/react-native @react-native-async-storage/async-storage react-native-webview react-native-safe-area-context
cd ios && pod installThe three peer dependencies are required:
Package | What the SDK uses it for |
|---|---|
| The anonymous id, the signed-in user, seen in-app messages, unsent messages |
| Help articles, which open as your help center's web page |
| Keeping the SDK's screens clear of the notch and the home indicator |
It needs React Native 0.74 or newer (Hermes, the New Architecture or the old one).
3. Start the SDK#
Call configure once, as early as you can, and wrap your app in <Agent44Provider>:
import { Agent44, Agent44Provider } from '@agent44/react-native';
import * as Application from 'expo-application'; // or react-native-device-info, below
Agent44.configure({
publicKeyIos: 'a44_pub_YOUR_IOS_KEY',
publicKeyAndroid: 'a44_pub_YOUR_ANDROID_KEY',
appInfo: {
appVersion: Application.nativeApplicationVersion,
build: Application.nativeBuildVersion,
bundleId: Application.applicationId,
},
});
export default function App() {
return (
<Agent44Provider>
<YourNavigation />
</Agent44Provider>
);
}<Agent44Provider> shows the SDK's screens over your app (in a modal with its own small stack, so it works with React Navigation, Expo Router or no navigator at all), the launch's in-app message, and banners. Put it inside your own providers and outside your navigator.
appInfo matters. React Native can't read your app's version without a native module, and the SDK has none, so pass it. agent44 uses the version to pick help articles, What's New and update prompts, and the bundle id to find your store page for "Update now". With react-native-device-info:
import DeviceInfo from 'react-native-device-info';
Agent44.configure({
publicKeyIos: '…',
publicKeyAndroid: '…',
appInfo: {
appVersion: DeviceInfo.getVersion(),
build: DeviceInfo.getBuildNumber(),
bundleId: DeviceInfo.getBundleId(),
deviceModel: DeviceInfo.getModel(),
},
});The platform, OS version, Android API level and Android device model are read from React Native itself. On iOS pass deviceModel (Device.modelName from expo-device, or DeviceInfo.getModel()) if you want your team to see it.
4. Add a chat button#
Put the round chat button in the corner of any screen. It shows the unread count, and a tap opens the chat:
import { Agent44Launcher } from '@agent44/react-native';
<View style={{ flex: 1 }}>
{/* your screen */}
<Agent44Launcher />
</View>It sits on the side set in agent44 (Settings › Inbox › Web messenger, Launcher position); pass position="left" or bottom={96} to move it. You can also open the chat from your own button:
<Button title="Chat with us" onPress={() => Agent44.openChat()} />That's it. Run your app, tap the button and send a message. It appears in your agent44 inbox, and the "Install the SDK" step in your dashboard's setup checklist ticks itself off.
Before you submit to the App Store or Google Play, see "Data the SDK collects" in the SDK's README.
Tell agent44 who your users are#
Call this after your user signs in, so your team knows who they're talking to and the user sees their conversations on every device:
await Agent44.identify({
userId: user.id, // your app's own user id
email: user.email, // everything else is optional
name: user.name,
phone: user.phone,
avatarUrl: user.photoUrl,
company: {
name: 'Acme',
url: 'https://acme.com',
employment: { title: 'CTO' },
geolocation: { city: 'London', country: 'GB' },
},
signature: user.agent44Hash, // see "Verify your users" below
});And when they sign out:
await Agent44.logout();identify rejects with an Agent44Error when agent44 can't be reached. Catch it and try again later: the previous identity stays in place until it works. logout never rejects for network errors, so it's safe to await in your sign-out flow.
People can chat before they sign in too. Their conversations move to their account when you call identify.
Verify your users#
Without verification, agent44 trusts the id you send. Anyone with your app's key and a user's id could then read that user's conversations. Identity verification stops that, and new workspaces start with it enforced: until your server signs user ids, identify is refused (401) and signed-in screens show their error state, while people who haven't signed in chat as usual.
In agent44, open Settings › Identity verification and click Generate secret. The secret starts with
a44_idv_and is shown only once: copy it into your server's configuration. It belongs on your server only. One secret covers every app in the workspace (iOS, Android and web).When your app signs in, have your server compute the HMAC-SHA256 of the user's id, keyed with the whole secret (the
a44_idv_included). Return it as lowercase hex.Pass it as
signaturetoAgent44.identify. The SDK sends it with every request (X-A44-User-Hash).If Enforce is off in your workspace, click Turn on Enforce once your app version with signatures is live.
// Node, on your server
crypto.createHmac('sha256', process.env.AGENT44_IDENTITY_SECRET).update(user.id).digest('hex');While Enforce is off, nothing is refused: a missing or wrong signature is ignored and the id is trusted as sent. While it's on, a user id with a missing or wrong signature gets a 401: identify rejects with an Agent44Error with statusCode 401 (and nothing is saved), and the screens show their error state. Use ids that can't be guessed either way: your database id or a UUID, not an email address or a number like 42.
Keep the signature out of backups (recommended with verification)#
The SDK keeps the signature on the device so the user stays signed in. With your app's key, the user id and signature are enough to act as that user. By default they're in AsyncStorage, which device backups copy. To keep them in the iOS Keychain and the Android Keystore, wrap a secure store in SecureIdentityStorage. It puts only the user id and signature there; everything else stays in AsyncStorage.
With expo-secure-store:
import * as SecureStore from 'expo-secure-store';
import { Agent44, SecureIdentityStorage, type Agent44Storage } from '@agent44/react-native';
const keychain: Agent44Storage = {
read: (key) => SecureStore.getItemAsync(`agent44.${key}`),
write: (key, value) =>
value === null
? SecureStore.deleteItemAsync(`agent44.${key}`)
: SecureStore.setItemAsync(`agent44.${key}`, value, { keychainAccessible: SecureStore.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY }),
};
Agent44.configure({ publicKeyIos: '…', publicKeyAndroid: '…', storage: new SecureIdentityStorage({ secure: keychain }) });With react-native-keychain:
import * as Keychain from 'react-native-keychain';
const keychain: Agent44Storage = {
read: async (key) => {
const item = await Keychain.getGenericPassword({ service: `agent44.${key}` });
return item ? item.password : null;
},
write: async (key, value) => {
if (value === null) await Keychain.resetGenericPassword({ service: `agent44.${key}` });
else await Keychain.setGenericPassword('agent44', value, { service: `agent44.${key}`, accessible: Keychain.ACCESSIBLE.AFTER_FIRST_UNLOCK_THIS_DEVICE_ONLY });
},
};Existing installs keep working. A user signed in by an earlier version is moved to the secure store on the next launch.
A reinstall starts signed out. Keychain items outlive the app on iOS, so the SDK ignores what it finds there until this install has written it.
logout()clears both stores. If the secure store can't delete, the SDK ignores what's left from then on.
Everything you can open#
Each of these is one line, called from any button or menu. They need <Agent44Provider> mounted, and resolve when the screen closes.
What | Code |
|---|---|
The chat (latest open conversation, or a new one) |
|
Messenger (home, messages, help and updates tabs) |
|
Start a new message |
|
One conversation |
|
The user's conversations |
|
Help center |
|
Search help |
|
Ask AI a question |
|
One help article |
|
What's new (changelog) |
|
One post |
|
The article id is the 10 characters after /articles/ in the article's web address.
Update prompts and What's New#
Force updates, recommended updates, What's New, announcements (modal, sheet or banner) and chat messages from a teammate are made in agent44's Engagement and shown by the SDK at launch: <Agent44Provider> fetches this launch's messages and shows the most important one (force update, recommended update, What's New, modal, chat, banner).
What's New shows after an update: the SDK remembers the last launch's app version and sends it with the current one (
appInfo.appVersionmust be set).Force updates can't be closed and only show with a store page to send the user to: the link set in agent44, else (from the
bundleIdinappInfo) Google Play's page on Android or the App Store page Apple's lookup finds on iOS. Without one the force update is skipped and logged.The SDK sends the OS version (and on Android the API level) so an update this device can't install is left out.
Turn the automatic check off with showInAppMessages: false, and call Agent44.checkInAppMessages() yourself when you're ready. To draw a message yourself, pass onInAppMessage: (message) => true and report what happened with Agent44.client.engagement.track(message.id, 'shown' | 'clicked' | 'dismissed').
Push notifications (optional)#
With push, users get a notification when your team or the AI agent replies (tapping it opens the conversation), and you can send push campaigns from agent44's Engagement. agent44 sends straight to Apple (APNs) for iOS and through Firebase Cloud Messaging for Android.
1. In agent44: open Settings › Apps, pick each app and set up Push notifications: your APNs .p8 key for iOS, your Firebase service account for Android.
2. In your app: hand the SDK the device's push token. On iOS that's the raw APNs device token (not an Expo push token or an FCM token); on Android, the FCM registration token.
With expo-notifications (a development build, not Expo Go, for push):
import * as Notifications from 'expo-notifications';
const { status } = await Notifications.requestPermissionsAsync();
const token = await Notifications.getDevicePushTokenAsync(); // APNs on iOS, FCM on Android
await Agent44.setPushToken(token.data, { enabled: status === 'granted' });
Notifications.addPushTokenListener((t) => void Agent44.setPushToken(t.data));
// A tap: a reply opens its conversation, a campaign opens its link.
Notifications.addNotificationResponseReceivedListener((response) => {
Agent44.handlePushTap(response.notification.request.content.data);
});
const last = Notifications.getLastNotificationResponse(); // the tap that launched the app
if (last) Agent44.handlePushTap(last.notification.request.content.data);
// While the app is open: keep the badge and the open conversation up to date.
Notifications.setNotificationHandler({
handleNotification: async (n) => {
const data = n.request.content.data;
const show = Agent44.isAgent44Push(data) ? Agent44.handleForegroundPush(data) : true;
return { shouldShowBanner: show, shouldShowList: show, shouldPlaySound: show, shouldSetBadge: false };
},
});With React Native Firebase (@react-native-firebase/messaging):
import { Platform } from 'react-native';
import messaging from '@react-native-firebase/messaging';
const status = await messaging().requestPermission();
const token = Platform.OS === 'ios' ? await messaging().getAPNSToken() : await messaging().getToken();
if (token) await Agent44.setPushToken(token, { enabled: status !== messaging.AuthorizationStatus.DENIED });
messaging().onNotificationOpenedApp((m) => Agent44.handlePushTap(m.data));
const initial = await messaging().getInitialNotification();
if (initial) Agent44.handlePushTap(initial.data);
messaging().onMessage((m) => Agent44.handleForegroundPush(m.data));Good to know:
sandbox(iOS only) defaults to__DEV__: development builds get sandbox pushes. Pass{ sandbox: false }for a release build you run from Xcode.A tap that launched the app waits up to 30 seconds for
configureand<Agent44Provider>, so callinghandlePushTapearly is fine. It's dropped if the user signs out first.Campaign links can be an
https://page or your app's own deep link (myapp://…), when you list its scheme indeepLinkSchemes. PassonOpenUrlto route them yourself:Agent44.handlePushTap(data, { onOpenUrl: (url) => router.push(url) }).The SDK reads only the
a44_type,a44_conversation_id,a44_message_idanda44_urlkeys; notifications withouta44_typeare your own, and the handlers returnfalsefor them.Agent44.logout()stops that user's notifications on the device.
Not yet in this version#
Compared with agent44 for Flutter 0.3.0:
No tablet layout. The messenger is the phone layout at every width; Flutter switches to a side navigation rail on wide screens.
No
embed(). The SDK's screens open over your app from<Agent44Provider>; you can't place one inside your own tab or screen yet.Simpler drawing. Icons are drawn with views rather than vector glyphs, and the brand gradient behind the chat and in-app messages is a banded tint, without Flutter's scattered brand dots.