npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@chative.io/react-native-widget

v0.5.2

Published

React Native SDK for Chative

Downloads

390

Readme

Chative.IO Widget for React Native

Chative.IO Widget is a React Native component that provides an easy-to-use chat widget for your mobile applications. It allows you to integrate a customizable chat interface with minimal setup.

Features

  • Customizable chat interface
  • Easy to show/hide programmatically
  • Supports custom header components
  • Supports filling user information into live chat. (v0.5 or higher)
  • Adjustable insets for different device sizes
  • TypeScript support

Screenshot

Installation

npm install @chative.io/react-native-widget
# or
yarn add @chative.io/react-native-widget

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

Usage

Here's a basic example of how to use the ChativeWidget in your React Native application:

import React, { useRef } from 'react';
import { Button, View } from 'react-native';
import ChativeWidget from '@chative.io/react-native-widget';

export default function App() {
  const widgetRef = useRef(null);

  const handleOpenChat = () => {
    widgetRef.current?.show();
  };

  const handleCloseChat = () => {
    // widgetRef.current?.hide();
  };

  const user = {
    user_id: 'UNIQUE_USER_ID',
     user: {
        email: '[email protected]', // Your user's email address
        first_name: 'John',
        last_name: 'Doe',
        phone: '+1234567890',
        custom_field: 'CUSTOMER_FIELD_VALUE' // Replace key and value with your custom field
    },
  }

  return (
    <View style={{ flex: 1 }}>
      <Button title="Open Chat" onPress={handleOpenChat} />
      <ChativeWidget
        ref={widgetRef}
        channelId="your-channel-id"
        user={user} // v0.5 or higher
        onClosed={() => console.log('Widget closed')}
        onLoaded={() => console.log('Widget loaded')}
        onNewMessage={(message) => console.log('New message:', message)}
        onError={(message) => console.log('Error', message)}
      />
    </View>
  );
}

Props

| Prop | Type | Required | Description | |------|------|----------|-------------| | channelId | string | Yes | The ID of the chat channel | | user | ChativeWidgetUser | No | Information about the user, used for booting into live chat. | headerComponent | ReactElement | No | Custom header component | | containerStyle | ViewStyle | No | Custom style for the container | | insetTop | number | No | Top inset (default: 50 for iOS, 20 for Android) | | insetBottom | number | No | Bottom inset (default: 50 for iOS, 20 for Android) | | onClosed | () => void | No | Callback when the widget is closed | | onLoaded | () => void | No | Callback when the widget is loaded | | onNewMessage | () => void | No | Callback when a new message is received | | onError | (error:string) => void | No | Callback function triggered when an error occurs. |

Methods

The following methods are available via the ref:

  • show(): Display the chat widget
  • hide(): Hide the chat widget
  • reload(): Reload the widget

Customization

You can customize the appearance of the widget by providing a custom header component and container style:

<ChativeWidget
  ref={widgetRef}
  channelId="your-channel-id"
  headerComponent={<YourCustomHeader />}
  containerStyle={{ backgroundColor: 'lightgray' }}
/>

TypeScript Support

This module includes TypeScript declarations. You can import types like this:

import ChativeWidget, { ChativeWidgetRef, ChativeWidgetUser } from '@chative.io/react-native-widget';

ChativeWidgetUser Interface

| Field | Type | Required | Description | |---------------|----------|----------|-------------| | user_id | string | Yes | A unique identifier for the user. This is used to track the user's session in the chat. | | user.email | string | No | The user's email address. Optional, but recommended for better user identification. | | user.first_name | string | No | The user's first name. Optional, useful for personalized interactions. | | user.last_name | string | No | The user's last name. Optional, useful for personalized interactions. | | user.phone | string | No | The user's phone number. Optional, can be used for follow-up contact. | | user.[key: string]: any | any | No | Any additional information about the user, represented as key-value pairs. This can be used for custom data. |

License

MIT License

Support

If you encounter any issues or have questions, please file an issue on the GitHub repository.