0.9.0 • Published 8 months ago
@atlasinc/react-native-sdk v0.9.0
@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-webviewUsage
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
0.9.0
8 months ago
0.8.1
10 months ago
0.7.2
10 months ago
0.6.3
11 months ago
0.8.0
10 months ago
0.7.1
10 months ago
0.6.2
11 months ago
0.8.3
10 months ago
0.8.2
10 months ago
0.6.4
11 months ago
0.7.0
10 months ago
0.6.1
1 year ago
0.6.0
1 year ago
0.5.5
2 years ago
0.5.4
2 years ago
0.5.3
2 years ago
0.5.0
2 years ago
0.4.1
2 years ago
0.5.2
2 years ago
0.5.1
2 years ago
0.4.0
3 years ago
0.3.0
3 years ago
0.2.1
3 years ago
0.3.2
3 years ago
0.3.1
3 years ago
0.2.0
3 years ago
0.1.1
3 years ago
0.1.0
3 years ago