0.0.5 • Published 3 months ago

msa-react-native-widget v0.0.5

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

Installation

Install the library using either yarn or npm like so:

yarn add msa-react-native-widget

OR

npm install --save msa-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 livechat channel in myserviceagent server by following the steps described here https://docs.google.com/document/d/1ssqPFbwZm5a0AoQtYHZR4LWesunB9piP8Vs6QQJ88MM/edit.
  2. Insert the websiteToken and baseUrl props. baseUrl is the url from which you are accessing the MSA engage CRM.
import React, { useState } from 'react';

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

import ChatWidget from 'msa-react-native-widget';

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

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

    </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;

You're done!

The whole example is in the /examples folder.

Props

Feedback

Feel free to send us feedback by contacting hello@myserviceagent.net

0.0.5

3 months ago

0.0.3

3 months ago

0.0.4

3 months ago

0.0.2

7 months ago

0.0.1

7 months ago