forked from walterholohan/react-native-crisp-chat-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
86 lines (82 loc) · 2.51 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import * as React from 'react';
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import CrispChat, {
CrispSessionEventColors,
pushSessionEvent,
resetSession,
setSessionSegment,
setSessionString,
setSessionBool,
setSessionInt,
setTokenId,
setUserAvatar,
setUserEmail,
setUserNickname,
setUserPhone,
} from 'react-native-crisp-chat-sdk';
export default function App() {
const [showChat, setShowChat] = React.useState<boolean>(false);
const onShowChat = () => {
setShowChat(!showChat);
};
return (
<View style={styles.container}>
<TouchableOpacity onPress={onShowChat}>
<Text>{showChat ? 'Hide' : 'Show'} Chat</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => setTokenId('123456789')}>
<Text>Set Token Id</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => setUserEmail('[email protected]')}>
<Text>Set User Email</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => setSessionString('stringkey', 'string value')}
>
<Text>Set Session String</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => setSessionBool('boolkey', true)}>
<Text>Set Session Boolean</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => setSessionInt('intkey', 10)}>
<Text>Set Session Int</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => setUserNickname('John Smith')}>
<Text>Set User Nickname</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => setUserPhone('+4412345678890')}>
<Text>Set User Phone</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() =>
setUserAvatar(
'https://s.gravatar.com/avatar/5bc4980ee481a05395a6d9cb3d61379c?s=80'
)
}
>
<Text>Set User Avatar</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => setSessionSegment('app')}>
<Text>Set Session Segment</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() =>
pushSessionEvent('Sign Up', CrispSessionEventColors.BLUE)
}
>
<Text>Push Session Segment</Text>
</TouchableOpacity>
<TouchableOpacity onPress={() => resetSession()}>
<Text>Reset Session</Text>
</TouchableOpacity>
{showChat && <CrispChat />}
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
});