Skip to content

Commit 43dad19

Browse files
Merge pull request #81 from cometchat-pro/v4-sample-app
feat: new sample v4.0.0
2 parents 7a972c8 + bf10375 commit 43dad19

File tree

116 files changed

+8641
-13108
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+8641
-13108
lines changed

CometChatWorkspace/.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Logs
2+
*.log
3+
npm-debug.log
4+
5+
# Runtime data
6+
tmp
7+
build
8+
lib
9+
10+
# Dependency directory
11+
node_modules
12+
*.DS_Store
13+
example/development2
14+
example/development
15+
# Build file for local testing
16+
cometchat-pro-react-native-ui-kit-1.0.0.tgz
17+
package-lock.json
18+
Pods
19+
.idea
20+
.gradle
21+
vendor

CometChatWorkspace/App.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect, useRef, useState } from 'react';
2-
import { PermissionsAndroid, Platform, SafeAreaView, StatusBar } from 'react-native';
3-
import { CometChat } from "@cometchat-pro/react-native-chat";
2+
import { PermissionsAndroid, Platform, SafeAreaView, StatusBar, Text } from 'react-native';
3+
import { CometChat } from "@cometchat/chat-sdk-react-native";
44
import { COMETCHAT_CONSTANTS } from './src/CONSTS';
55
import { CometChatContextProvider } from '@cometchat/chat-uikit-react-native';
66
import { CometChatTheme } from '@cometchat/chat-uikit-react-native';
@@ -85,6 +85,15 @@ const App = () => {
8585
onDecline={(call) => {
8686
setCallReceived(false)
8787
}}
88+
incomingCallStyle={{
89+
backgroundColor: 'white',
90+
titleColor: 'black',
91+
subtitleColor: 'gray',
92+
titleFont: {
93+
fontSize: 20,
94+
fontWeight: 'bold'
95+
}
96+
}}
8897
/>
8998
}
9099
<UserContextProvider>

CometChatWorkspace/App.tsx

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
2+
import React, { useEffect, useRef, useState } from 'react';
3+
import { PermissionsAndroid, Platform, SafeAreaView, StatusBar, Text } from 'react-native';
4+
import { CometChat } from "@cometchat/chat-sdk-react-native";
5+
import { COMETCHAT_CONSTANTS } from './src/CONSTS';
6+
import { CometChatContextProvider, CometChatConversationsWithMessages } from '@cometchat/chat-uikit-react-native';
7+
import { CometChatTheme } from '@cometchat/chat-uikit-react-native';
8+
import { CometChatUIKit } from '@cometchat/chat-uikit-react-native';
9+
import StackNavigator from './src/StackNavigator';
10+
import { UserContextProvider } from './UserContext';
11+
import { CometChatIncomingCall } from '@cometchat/chat-uikit-react-native';
12+
import { CometChatUIEventHandler } from '@cometchat/chat-uikit-react-native';
13+
var listnerID = "UNIQUE_LISTENER_ID";
14+
15+
const App = () => {
16+
17+
const getPermissions = () => {
18+
if (Platform.OS == "android") {
19+
PermissionsAndroid.requestMultiple([
20+
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
21+
PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
22+
PermissionsAndroid.PERMISSIONS.CAMERA,
23+
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO,
24+
]);
25+
}
26+
}
27+
28+
const [callRecevied, setCallReceived] = useState(false);
29+
const incomingCall = useRef(null);
30+
31+
useEffect(() => {
32+
getPermissions();
33+
CometChatUIKit.init({
34+
appId: COMETCHAT_CONSTANTS.APP_ID,
35+
authKey: COMETCHAT_CONSTANTS.AUTH_KEY,
36+
region: COMETCHAT_CONSTANTS.REGION,
37+
})
38+
.then(() => {
39+
if (CometChat.setSource) {
40+
CometChat.setSource('ui-kit', Platform.OS, 'react-native');
41+
}
42+
})
43+
.catch(() => {
44+
return null;
45+
});
46+
47+
CometChat.addCallListener(
48+
listnerID,
49+
new CometChat.CallListener({
50+
onIncomingCallReceived: (call) => {
51+
incomingCall.current = call;
52+
setCallReceived(true);
53+
},
54+
onOutgoingCallRejected: (call) => {
55+
incomingCall.current = null;
56+
setCallReceived(false);
57+
},
58+
onIncomingCallCancelled: (call) => {
59+
incomingCall.current = null;
60+
setCallReceived(false);
61+
}
62+
})
63+
);
64+
65+
CometChatUIEventHandler.addCallListener(listnerID, {
66+
ccCallEnded: () => {
67+
incomingCall.current = null;
68+
setCallReceived(false);
69+
},
70+
});
71+
72+
return () => {
73+
CometChatUIEventHandler.removeCallListener(listnerID);
74+
CometChat.removeCallListener(listnerID)
75+
}
76+
77+
}, []);
78+
79+
return (
80+
<SafeAreaView style={{ flex: 1 }}>
81+
<StatusBar backgroundColor={"white"} barStyle={"dark-content"} />
82+
{
83+
callRecevied &&
84+
<CometChatIncomingCall
85+
call={incomingCall.current}
86+
onDecline={(call) => {
87+
setCallReceived(false)
88+
}}
89+
incomingCallStyle={{
90+
backgroundColor: 'white',
91+
titleColor: 'black',
92+
subtitleColor: 'gray',
93+
titleFont: {
94+
fontSize: 20,
95+
fontWeight: 'bold'
96+
}
97+
}}
98+
/>
99+
}
100+
<UserContextProvider>
101+
<CometChatContextProvider theme={new CometChatTheme({})}>
102+
<StackNavigator />
103+
</CometChatContextProvider>
104+
</UserContextProvider>
105+
</SafeAreaView>
106+
);
107+
};
108+
109+
export default App;

CometChatWorkspace/Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source 'https://rubygems.org'
22

33
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4-
ruby '2.7.4'
4+
ruby ">= 2.6.10"
55

6-
gem 'cocoapods', '~> 1.11', '>= 1.11.2'
6+
gem 'cocoapods', '~> 1.12'

CometChatWorkspace/Gemfile.lock

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
CFPropertyList (3.0.5)
4+
CFPropertyList (3.0.6)
55
rexml
6-
activesupport (6.1.7)
6+
activesupport (6.1.7.6)
77
concurrent-ruby (~> 1.0, >= 1.0.2)
88
i18n (>= 1.6, < 2)
99
minitest (>= 5.1)
1010
tzinfo (~> 2.0)
1111
zeitwerk (~> 2.3)
12-
addressable (2.8.1)
12+
addressable (2.8.5)
1313
public_suffix (>= 2.0.2, < 6.0)
1414
algoliasearch (1.27.5)
1515
httpclient (~> 2.8, >= 2.8.3)
1616
json (>= 1.5.1)
1717
atomos (0.1.3)
1818
claide (1.1.0)
19-
cocoapods (1.11.3)
19+
cocoapods (1.12.1)
2020
addressable (~> 2.8)
2121
claide (>= 1.0.2, < 2.0)
22-
cocoapods-core (= 1.11.3)
22+
cocoapods-core (= 1.12.1)
2323
cocoapods-deintegrate (>= 1.0.3, < 2.0)
24-
cocoapods-downloader (>= 1.4.0, < 2.0)
24+
cocoapods-downloader (>= 1.6.0, < 2.0)
2525
cocoapods-plugins (>= 1.0.0, < 2.0)
2626
cocoapods-search (>= 1.0.0, < 2.0)
27-
cocoapods-trunk (>= 1.4.0, < 2.0)
27+
cocoapods-trunk (>= 1.6.0, < 2.0)
2828
cocoapods-try (>= 1.1.0, < 2.0)
2929
colored2 (~> 3.1)
3030
escape (~> 0.0.4)
3131
fourflusher (>= 2.3.0, < 3.0)
3232
gh_inspector (~> 1.0)
3333
molinillo (~> 0.8.0)
3434
nap (~> 1.0)
35-
ruby-macho (>= 1.0, < 3.0)
35+
ruby-macho (>= 2.3.0, < 3.0)
3636
xcodeproj (>= 1.21.0, < 2.0)
37-
cocoapods-core (1.11.3)
38-
activesupport (>= 5.0, < 7)
37+
cocoapods-core (1.12.1)
38+
activesupport (>= 5.0, < 8)
3939
addressable (~> 2.8)
4040
algoliasearch (~> 1.0)
4141
concurrent-ruby (~> 1.1)
@@ -54,7 +54,7 @@ GEM
5454
netrc (~> 0.11)
5555
cocoapods-try (1.2.0)
5656
colored2 (3.1.2)
57-
concurrent-ruby (1.1.10)
57+
concurrent-ruby (1.2.2)
5858
escape (0.0.4)
5959
ethon (0.16.0)
6060
ffi (>= 1.15.0)
@@ -63,20 +63,20 @@ GEM
6363
fuzzy_match (2.0.4)
6464
gh_inspector (1.1.3)
6565
httpclient (2.8.3)
66-
i18n (1.12.0)
66+
i18n (1.14.1)
6767
concurrent-ruby (~> 1.0)
68-
json (2.6.2)
69-
minitest (5.16.3)
68+
json (2.6.3)
69+
minitest (5.19.0)
7070
molinillo (0.8.0)
7171
nanaimo (0.3.0)
7272
nap (1.1.0)
7373
netrc (0.11.0)
7474
public_suffix (4.0.7)
75-
rexml (3.2.5)
75+
rexml (3.2.6)
7676
ruby-macho (2.5.1)
7777
typhoeus (1.4.0)
7878
ethon (>= 0.9.0)
79-
tzinfo (2.0.5)
79+
tzinfo (2.0.6)
8080
concurrent-ruby (~> 1.0)
8181
xcodeproj (1.22.0)
8282
CFPropertyList (>= 2.3.3, < 4.0)
@@ -85,16 +85,16 @@ GEM
8585
colored2 (~> 3.1)
8686
nanaimo (~> 0.3.0)
8787
rexml (~> 3.2.4)
88-
zeitwerk (2.6.5)
88+
zeitwerk (2.6.11)
8989

9090
PLATFORMS
9191
ruby
9292

9393
DEPENDENCIES
94-
cocoapods (~> 1.11, >= 1.11.2)
94+
cocoapods (~> 1.12)
9595

9696
RUBY VERSION
97-
ruby 2.7.4p191
97+
ruby 2.6.10p210
9898

9999
BUNDLED WITH
100-
2.2.27
100+
1.17.2

CometChatWorkspace/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).
2+
3+
# Getting Started
4+
5+
>**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding.
6+
7+
## Step 1: Start the Metro Server
8+
9+
First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native.
10+
11+
To start Metro, run the following command from the _root_ of your React Native project:
12+
13+
```bash
14+
# using npm
15+
npm start
16+
17+
# OR using Yarn
18+
yarn start
19+
```
20+
21+
## Step 2: Start your Application
22+
23+
Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app:
24+
25+
### For Android
26+
27+
```bash
28+
# using npm
29+
npm run android
30+
31+
# OR using Yarn
32+
yarn android
33+
```
34+
35+
### For iOS
36+
37+
```bash
38+
# using npm
39+
npm run ios
40+
41+
# OR using Yarn
42+
yarn ios
43+
```
44+
45+
If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly.
46+
47+
This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.
48+
49+
## Step 3: Modifying your App
50+
51+
Now that you have successfully run the app, let's modify it.
52+
53+
1. Open `App.tsx` in your text editor of choice and edit some lines.
54+
2. For **Android**: Press the <kbd>R</kbd> key twice or select **"Reload"** from the **Developer Menu** (<kbd>Ctrl</kbd> + <kbd>M</kbd> (on Window and Linux) or <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> (on macOS)) to see your changes!
55+
56+
For **iOS**: Hit <kbd>Cmd ⌘</kbd> + <kbd>R</kbd> in your iOS Simulator to reload the app and see your changes!
57+
58+
## Congratulations! :tada:
59+
60+
You've successfully run and modified your React Native App. :partying_face:
61+
62+
### Now what?
63+
64+
- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
65+
- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started).
66+
67+
# Troubleshooting
68+
69+
If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.
70+
71+
# Learn More
72+
73+
To learn more about React Native, take a look at the following resources:
74+
75+
- [React Native Website](https://reactnative.dev) - learn more about React Native.
76+
- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
77+
- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
78+
- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
79+
- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.

CometChatWorkspace/UserContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CometChat } from '@cometchat-pro/react-native-chat';
1+
import { CometChat } from '@cometchat/chat-sdk-react-native';
22
import React, { createContext, useState } from 'react';
33

44
export const UserContext = createContext<{

CometChatWorkspace/__tests__/App-test.js renamed to CometChatWorkspace/__tests__/App.test.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import 'react-native';
66
import React from 'react';
77
import App from '../App';
88

9+
// Note: import explicitly to use the types shiped with jest.
10+
import {it} from '@jest/globals';
11+
912
// Note: test renderer must be required after react-native.
1013
import renderer from 'react-test-renderer';
1114

0 commit comments

Comments
 (0)