-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
70 lines (48 loc) · 1.77 KB
/
Copy pathApp.js
File metadata and controls
70 lines (48 loc) · 1.77 KB
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
import React, { useEffect, useContext, useState } from 'react';
import { StyleSheet, SafeAreaView, StatusBar, AppRegistry } from 'react-native';
import { StreamChat } from 'stream-chat';
import { OverlayProvider, Chat } from 'stream-chat-expo';
import Navigation from './src/navigation';
import Amplify,{ Auth, DataStore} from 'aws-amplify';
import awsconfig from './src/aws-exports'
import AuthContext from './src/contexts/Authentication';
Amplify.configure(awsconfig)
const API_KEY = '4gqynpstsrwm';
const client = StreamChat.getInstance(API_KEY);
export default function App() {
const [user, setUser] = useState('');
const [otherUser, setOtherUser] = useState('');
useEffect(() => {
/*
Amplify provides a unique user identifier (userSub),
which can be passed as userToken to create a link between the user in the stream database
and the user in the amplify database.
*/
// stream only allows one client connected at a time. On dismount, disconnect user
// console.log(client);
return () => client.disconnectUser();
}, []);
console.disableYellowBox = true;
return (
<SafeAreaView style={styles.container}>
<AuthContext.Provider value={{user, setUser, otherUser, setOtherUser}}>
<OverlayProvider>
{/*
Could encapsulate only the message screen with the chat component
However, this may effect notifications from coming through when the user is on another screen
*/}
<Chat client={client}>
<StatusBar />
{/* Navigation will go here */}
<Navigation />
</Chat>
</OverlayProvider>
</AuthContext.Provider>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});