UNPKG

react-native-hubspot-chat

Version:

A React Native wrapper for the **HubSpot Mobile Chat SDK** for both iOS and Android.

131 lines (86 loc) โ€ข 3.23 kB
# React Native HubSpot Chat A React Native wrapper for the **HubSpot Mobile Chat SDK** for both iOS and Android. This package internally uses the official SDK provided by hubspot: iOS: https://github.com/HubSpot/mobile-chat-sdk-ios Android: https://github.com/HubSpot/mobile-chat-sdk-android This package allows you to integrate **HubSpot's Mobile Chatflow** into your React Native app, with clean API, full TypeScript support, and native performance. --- ## โœ… Features - ๐Ÿ“ฑ Supports **iOS (Swift)** and **Android (Kotlin)** - โœ… Native module bridge using TurboModules compatibility - ๐ŸŽฏ Supports **TypeScript** - ๐Ÿ’ฌ Chatflow integration with a single method - ๐Ÿ” Visitor identification supported - ๐Ÿ“ฆ Includes full documentation and open to contributions --- ## โš™๏ธ Setup ### iOS You need to get your plist file with hubspot configuration from your hubspot account. This is required for the chat to work. **Note:The naming of the file should be exactly as mentioned below.** 1. Add `Hubspot-Info.plist` to your iOS project: - Open Xcode โ†’ Right-click on the app โ†’ `Add Files to [YourApp]...` - Select `Hubspot-Info.plist` - Make sure the file is added to the main app target (check the checkbox) 2. Install pods: ```sh cd ios && pod install ``` --- ### Android 1. Download your `hubspot-info.json` file from Hubspot Console 2. Place it inside `android/app/src/main/assets/` (Create this folder if not already existing) --- ## ๐Ÿš€ Installation ```sh yarn add react-native-hubspot-chat cd ios && pod install ``` --- ## ๐Ÿงช Usage ### Initialize SDK Initialise the SDK at the start of the app, please ensure your ios and android conifguration is done properly or this will fail. ```js import HubspotChat from 'react-native-hubspot-chat'; await HubspotChat.init(); ``` ### Identify Visitor You would need to have an identity token from hubspot first. Please read here for more details: https://developers.hubspot.com/docs/guides/api/conversations/mobile-chat-sdk/ios#identify-users-with-the-hubspot-visitor-identification-token ```js await HubspotChat.identify('your_signed_identity_token', 'user@example.com'); ``` ### Set custom chat properties ```js await HubspotChat.setProperties([ { name: 'plan', value: 'pro' }, { name: 'theme', value: 'dark' } ]); ``` ### Open Chat ```js await HubspotChat.open('your-chatflow-tag'); ``` --- ## ๐Ÿงฉ TypeScript Support This module includes `.d.ts` definitions out-of-the-box. ```ts HubspotChat.init(): Promise<void>; HubspotChat.open(tag: string): Promise<void>; HubspotChat.identify(identityToken: string, email?: string): Promise<void>; HubspotChat.setProperties(props: { name: string; value: string }[] | Record<string, string>): Promise<void>; HubspotChat.endSession(): Promise<void>; ``` --- ## ๐Ÿ“ Files to Include | File | Platform | Required | |-----------------------|----------|----------| | `hubspot-info.json` | Android | โœ… | | `Hubspot-Info.plist` | iOS | โœ… | --- ## ๐Ÿค Contributing See [CONTRIBUTING.md](CONTRIBUTING.md) for development instructions. --- ## ๐Ÿ“„ License MIT โ€“ see [LICENSE](LICENSE) ## TODO - Add support for push notifications for chat