-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathApp.tsx
102 lines (94 loc) · 3 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import React, {useLayoutEffect, useRef, useState} from 'react';
import {
PermissionsAndroid,
Platform,
SafeAreaView,
StatusBar,
} from 'react-native';
import {CometChat} from '@cometchat/chat-sdk-react-native';
import {CometChatContextProvider} from '@cometchat/chat-uikit-react-native';
import {CometChatTheme} from '@cometchat/chat-uikit-react-native';
import StackNavigator from './src/StackNavigator';
import {UserContextProvider} from './UserContext';
import {CometChatIncomingCall} from '@cometchat/chat-uikit-react-native';
import {CometChatUIEventHandler} from '@cometchat/chat-uikit-react-native';
var listnerID = 'UNIQUE_LISTENER_ID';
const App = () => {
const getPermissions = () => {
if (Platform.OS == 'android') {
PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
PermissionsAndroid.PERMISSIONS.CAMERA,
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
]);
}
};
const [callRecevied, setCallReceived] = useState(false);
const incomingCall = useRef(null);
useLayoutEffect(() => {
getPermissions();
CometChat.setDemoMetaInfo({
name: "React Native Push Notification Sample App",
type: "push-notification-react-native",
version: "1.0",
platform: "react-native",
});
// CometChat.addCallListener(
// listnerID,
// new CometChat.CallListener({
// onIncomingCallReceived: (call: any) => {
// incomingCall.current = call;
// setCallReceived(true);
// },
// onOutgoingCallRejected: (call: any) => {
// incomingCall.current = null;
// setCallReceived(false);
// },
// onIncomingCallCancelled: (call: any) => {
// incomingCall.current = null;
// setCallReceived(false);
// },
// }),
// );
CometChatUIEventHandler.addCallListener(listnerID, {
ccCallEnded: () => {
incomingCall.current = null;
setCallReceived(false);
},
});
return () => {
CometChatUIEventHandler.removeCallListener(listnerID);
CometChat.removeCallListener(listnerID);
};
}, []);
return (
<SafeAreaView style={{flex: 1}}>
<StatusBar backgroundColor={'white'} barStyle={'dark-content'} />
{/* {callRecevied && (
<CometChatIncomingCall
//@ts-ignore
call={incomingCall.current}
onDecline={call => {
setCallReceived(false);
}}
incomingCallStyle={{
backgroundColor: 'white',
titleColor: 'black',
subtitleColor: 'gray',
titleFont: {
fontSize: 20,
fontWeight: 'bold',
},
}}
/>
)} */}
<UserContextProvider>
<CometChatContextProvider theme={new CometChatTheme({})}>
<StackNavigator />
</CometChatContextProvider>
</UserContextProvider>
</SafeAreaView>
);
};
export default App;