Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@atlasinc/react-native-sdk

Package Overview
Dependencies
Maintainers
0
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atlasinc/react-native-sdk

test

  • 0.6.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

@atlasinc/react-native-sdk

Atlas customer support chat widget

Installation

This module requires react-native-webview to be installed:

npm install @atlasinc/react-native-sdk react-native-webview

Usage

import React, { useState, useEffect, useContext } from 'react';
import { createAtlasSupportSDK } from '@atlasinc/react-native-sdk';

// For demo purpose, assume that user credentials are stored in the React context
import UserContext from './user-context';

// The APP_ID can be found on Atlas Company Settings page: https://app.atlas.so/settings/company
const {
  // Authentication method
  identify,
  // Realtime updates on conversations status
  watchAtlasSupportStats,
  // Manually set custom ticket fields
  updateAtlasCustomFields,
  // Chat widget
  AtlasSupportWidget
} = createAtlasSupportSDK({
  // Application ID can be found at https://app.atlas.so/settings/company
  appId: 'APP_ID',
  // Optional user data that can be set later via identify() function
  userId: '',
  userHash: '',
  userName: '',
  userEmail: '',
  // Optional error callback
  onError: (error) => console.error(error)
});

function Component() {
  // User identification
  const user = useContext(UserContext);
  useEffect(() => {
    // Read more about Atlas authentication: https://help.atlas.so/articles/620722-user-authentication
    identify({
      userId: user.id,
      userHash: user.atlasHash,
      userName: user.fullName,
      userEmail: user.email
    });
  }, [user]);

  // Unread messages counter
  const [unread, setUnread] = useState(0);
  useEffect(() => {
    const unsubscribe = watchAtlasSupportStats(({ conversations }) => {
      // Counting amount of unread messages from each conversation
      const unreadTotal = conversations.reduce((total, c) => total + c.unread, 0);
      setUnread(unreadTotal);
    });
    return unsubscribe;
  }, []);

  // Using chat widget
  return (
    <View>
      <AtlasSupportWidget
        style={{ flex: 1 }}
        onNewTicket={(data) => updateAtlasCustomFields(data.ticketId, { customTicketField: 'value' })}
      />
    </View>
  );
}

License

MIT


Made with create-react-native-library

Keywords

FAQs

Package last updated on 03 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc