react-native-hubspot-sdk
v1.0.4
Published
React Native bridge for HubSpot Live Chat SDK, providing easy integration for iOS and Android
Maintainers
Readme
React Native HubSpot SDK
React Native bridge for HubSpot Live Chat SDK, providing easy integration for iOS and Android platforms.
Features
- 🚀 Easy integration with HubSpot Live Chat
- 📱 Cross-platform support (iOS & Android)
- 🔧 TypeScript support
- 🎯 Simple API with Promise-based methods
- 👤 User identification and chat properties
- 🔐 Secure authentication with identity tokens
Installation
npm install react-native-hubspot-sdk
# or
yarn add react-native-hubspot-sdkiOS Setup
- Add the following to your
ios/Podfile:
pod 'react-native-hubspot-sdk', :path => '../node_modules/react-native-hubspot-sdk'- Run pod install:
cd ios && pod installAndroid Setup
The package will be automatically linked with React Native 0.60+
Make sure your
android/build.gradlehas the following configuration:
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://www.jitpack.io" }
}
}Usage
Basic Setup
import HubspotSdk from 'react-native-hubspot-sdk';
// Configure the SDK (call this once in your app)
await HubspotSdk.configure();
// Open chat with a specific tag
await HubspotSdk.openChat('your-chat-tag');User Identification
// Identify user with identity token
await HubspotSdk.identify('user-identity-token', '[email protected]');Setting Chat Properties
The setProperties method handles platform differences automatically:
// For iOS - use array format
const iosProps = [
{ name: 'user_type', value: 'premium' },
{ name: 'subscription_plan', value: 'pro' }
];
// For Android - use object format
const androidProps = {
user_type: 'premium',
subscription_plan: 'pro'
};
// The SDK handles platform differences automatically
await HubspotSdk.setProperties(iosProps); // Works on both platforms
await HubspotSdk.setProperties(androidProps); // Works on both platformsLogout
// Logout current user
await HubspotSdk.logout();API Reference
configure(): Promise<void>
Configures the HubSpot SDK. Call this method once when your app starts.
openChat(tag: string): Promise<void>
Opens the HubSpot chat interface with the specified chat flow tag.
Parameters:
tag(string): The chat flow tag configured in your HubSpot dashboard
identify(identityToken: string, email?: string): Promise<void>
Identifies the current user with HubSpot.
Parameters:
identityToken(string): User identity token from your authentication systememail(string, optional): User's email address
setProperties(props: ChatProperties): Promise<void>
Sets chat properties for the current conversation.
Parameters:
props(ChatProperties): Properties to set- iOS: Array of
{ name: string, value: string }objects - Android: Object with string key-value pairs
- The SDK automatically handles platform differences
- iOS: Array of
logout(): Promise<void>
Logs out the current user from HubSpot chat.
TypeScript Support
This package includes TypeScript definitions. Import types as needed:
import HubspotSdk, { ChatProperty, ChatProperties, HubspotSdkInterface } from 'react-native-hubspot-sdk';
const properties: ChatProperties = [
{ name: 'user_type', value: 'premium' }
];
await HubspotSdk.setProperties(properties);Author
DevSon [email protected]
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
