UNPKG

react-native-hubspot-chat

Version:

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

29 lines (26 loc) 845 B
import { NativeModules, Platform } from 'react-native'; const { HubspotModule } = NativeModules; function setProperties(props) { if (Platform.OS === 'ios') { if (!Array.isArray(props)) { throw new Error('iOS requires an array of {name, value} objects'); } return HubspotModule.setChatProperties(props); } else { if (Array.isArray(props)) { const map = {}; props.forEach(({ name, value }) => { map[name] = value; }); return HubspotModule.setChatProperties(map); } return HubspotModule.setChatProperties(props); } } export default { init: () => HubspotModule.initSDK(), open: (tag) => HubspotModule.openChat(tag), identify: (identityToken, email) => HubspotModule.identifyVisitor(identityToken, email), setProperties, endSession: () => HubspotModule.endSession(), };