@helpway/react-native
v0.1.0
Published
Helpway in-app support for React Native and Expo — no floating launcher; your app opens the messenger from its own Help entry.
Maintainers
Readme
@helpway/react-native
Helpway in-app support for React Native and Expo.
There is no floating chat bubble. Your app opens the messenger from its own "Help" or "Contact support" entry, and it slides up as a sheet. This works in Expo Go: the only native module is react-native-webview, which Expo ships.
Install
npx expo install react-native-webview
npm install @helpway/react-nativeUse
import { HelpwayProvider, useHelpway, useHelpwayUnread } from "@helpway/react-native";
export default function App() {
const user = useCurrentUser(); // yours
return (
<HelpwayProvider
publicKey="pk_live_..."
user={user ? { externalId: user.id, email: user.email, name: user.name } : null}
onError={(reason) => console.warn("Helpway:", reason)}
>
<Navigation />
</HelpwayProvider>
);
}
function HelpRow() {
const helpway = useHelpway();
const unread = useHelpwayUnread(); // null until known
return (
<Pressable onPress={helpway.present}>
<Text>Help{unread ? ` (${unread})` : ""}</Text>
</Pressable>
);
}| Call | Opens |
|---|---|
| present() | the messenger's home |
| presentComposer(text?) | a new conversation, with text already typed |
| presentConversation(id) | one conversation, e.g. from a notification |
| dismiss() | closes the sheet |
A badge before the first open
Pass storage and the SDK keeps this app's visitor on the device. It then asks for the unread count on its own: at launch, and whenever the app comes back to the foreground. useHelpwayUnread() is then correct before anyone has tapped Help.
npx expo install @react-native-async-storage/async-storageimport AsyncStorage from "@react-native-async-storage/async-storage";
<HelpwayProvider publicKey="pk_live_..." storage={AsyncStorage}>Without storage, the count is null until the sheet has been opened once. null means "not known". Draw no badge for it rather than a 0 that may not be true.
Props
| Prop | |
|---|---|
| publicKey | Your workspace's public key (pk_live_…), from Settings → API keys |
| user | Whoever is signed in, or null when nobody is |
| storage | Optional. Anything with async getItem / setItem / removeItem, such as AsyncStorage |
| locale | Optional. Pin a language, e.g. "tr", instead of the messenger's own detection |
| colorScheme | Optional. "light" or "dark" instead of following the phone |
| onError | Called when the messenger can't open or reports a problem |
Who the user is
Pass user whenever someone is signed in, and null when nobody is. When it changes (a logout, or a different login), the SDK forgets the previous person. The next open then starts a fresh visitor, so the next person on the phone never sees the last one's conversations. If that reset can't be done (you're offline), the sheet closes and onError gets called. It does not open for the wrong person.
What this version does not do yet (#268)
- Push notifications for replies that arrive while the app is closed.
- Text: the SDK shows none of its own. Failures go to
onError, in your words and your language.
