0.0.22 • Published 3 years ago

@chatwoot/chatwoot-react-native-widget-testing v0.0.22

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

npm.io npm.io PRs Welcome npm.io

  • Supported Chatwoot version: 1.13.2+

Installation

Install the library using either yarn or npm like so:

yarn add chatwoot-react-native-widget

OR

npm install --save chatwoot-react-native-widget

This library depends on react-native-webview and async-storage. Please follow the instructions provided in the docs.

iOS Installation

If you're using React Native versions > 60.0, it's relatively straightforward.

cd ios && pod install

How to use

  1. Create a website channel in chatwoot server by following the steps described here https://www.chatwoot.com/docs/channels/website
  2. Replace websiteToken prop
import React, { useState } from 'react';

import { StyleSheet, View, SafeAreaView, TouchableOpacity, Text } from 'react-native';

import ChatWootWidget from 'chatwoot-react-native-widget';

const App = () => {
  const [showWidget, toggleWidget] = useState(false);
  const user = {
    identifier: 'john@gmail.com',
    name: 'John Samuel',
    avatar_url: '',
    email: 'john@gmail.com',
    identifier_hash: '',
  };
  const customAttributes = { accountId: 1, pricingPlan: 'paid', status: 'active' };
  const websiteToken = 'WEBSITE_TOKEN';
  const baseUrl = 'CHATWOOT_INSTALLATION_URL';
  const locale = 'en';

  return (
    <SafeAreaView style={styles.container}>
      <View>
        <TouchableOpacity style={styles.button} onPress={() => toggleWidget(true)}>
          <Text style={styles.buttonText}>Open widget</Text>
        </TouchableOpacity>
      </View>
      <ChatWootWidget
          websiteToken={websiteToken}
          locale={locale}
          baseUrl={baseUrl}
          closeModal={() => toggleWidget(false)}
          isModalVisible={showWidget}
          user={user}
          customAttributes={customAttributes}
        />
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },

  button: {
    height: 48,
    marginTop: 32,
    paddingTop: 8,
    paddingBottom: 8,
    backgroundColor: '#1F93FF',
    borderRadius: 8,
    borderWidth: 1,
    borderColor: '#fff',
    justifyContent: 'center',
  },
  buttonText: {
    color: '#fff',
    textAlign: 'center',
    paddingLeft: 10,
    fontWeight: '600',
    fontSize: 16,
    paddingRight: 10,
  },
});

export default App;

Props

Feedback & Contributing

Feel free to send us feedback on Twitter or file an issue.

If there's anything you'd like to chat about, please feel free to join our Discord chat!

Chatwoot © 2017-2020, Chatwoot Inc - Released under the MIT License.

0.0.22

3 years ago

0.0.19

3 years ago

0.0.15

3 years ago

0.0.16

3 years ago

0.0.17

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.9

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago