Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CometChatWorkspace/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Logs
*.log
npm-debug.log

# Runtime data
tmp
build
lib

# Dependency directory
node_modules
*.DS_Store
example/development2
example/development
# Build file for local testing
cometchat-pro-react-native-ui-kit-1.0.0.tgz
package-lock.json
Pods
.idea
.gradle
vendor
13 changes: 11 additions & 2 deletions CometChatWorkspace/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useRef, useState } from 'react';
import { PermissionsAndroid, Platform, SafeAreaView, StatusBar } from 'react-native';
import { CometChat } from "@cometchat-pro/react-native-chat";
import { PermissionsAndroid, Platform, SafeAreaView, StatusBar, Text } from 'react-native';
import { CometChat } from "@cometchat/chat-sdk-react-native";
import { COMETCHAT_CONSTANTS } from './src/CONSTS';
import { CometChatContextProvider } from '@cometchat/chat-uikit-react-native';
import { CometChatTheme } from '@cometchat/chat-uikit-react-native';
Expand Down Expand Up @@ -85,6 +85,15 @@ const App = () => {
onDecline={(call) => {
setCallReceived(false)
}}
incomingCallStyle={{
backgroundColor: 'white',
titleColor: 'black',
subtitleColor: 'gray',
titleFont: {
fontSize: 20,
fontWeight: 'bold'
}
}}
/>
}
<UserContextProvider>
Expand Down
109 changes: 109 additions & 0 deletions CometChatWorkspace/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@

import React, { useEffect, useRef, useState } from 'react';
import { PermissionsAndroid, Platform, SafeAreaView, StatusBar, Text } from 'react-native';
import { CometChat } from "@cometchat/chat-sdk-react-native";
import { COMETCHAT_CONSTANTS } from './src/CONSTS';
import { CometChatContextProvider, CometChatConversationsWithMessages } from '@cometchat/chat-uikit-react-native';
import { CometChatTheme } from '@cometchat/chat-uikit-react-native';
import { CometChatUIKit } 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);

useEffect(() => {
getPermissions();
CometChatUIKit.init({
appId: COMETCHAT_CONSTANTS.APP_ID,
authKey: COMETCHAT_CONSTANTS.AUTH_KEY,
region: COMETCHAT_CONSTANTS.REGION,
})
.then(() => {
if (CometChat.setSource) {
CometChat.setSource('ui-kit', Platform.OS, 'react-native');
}
})
.catch(() => {
return null;
});

CometChat.addCallListener(
listnerID,
new CometChat.CallListener({
onIncomingCallReceived: (call) => {
incomingCall.current = call;
setCallReceived(true);
},
onOutgoingCallRejected: (call) => {
incomingCall.current = null;
setCallReceived(false);
},
onIncomingCallCancelled: (call) => {
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
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;
4 changes: 2 additions & 2 deletions CometChatWorkspace/Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://rubygems.org'

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

gem 'cocoapods', '~> 1.11', '>= 1.11.2'
gem 'cocoapods', '~> 1.12'
40 changes: 20 additions & 20 deletions CometChatWorkspace/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.5)
CFPropertyList (3.0.6)
rexml
activesupport (6.1.7)
activesupport (6.1.7.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.1)
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
claide (1.1.0)
cocoapods (1.11.3)
cocoapods (1.12.1)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.11.3)
cocoapods-core (= 1.12.1)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 1.4.0, < 2.0)
cocoapods-downloader (>= 1.6.0, < 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.4.0, < 2.0)
cocoapods-trunk (>= 1.6.0, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
fourflusher (>= 2.3.0, < 3.0)
gh_inspector (~> 1.0)
molinillo (~> 0.8.0)
nap (~> 1.0)
ruby-macho (>= 1.0, < 3.0)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.21.0, < 2.0)
cocoapods-core (1.11.3)
activesupport (>= 5.0, < 7)
cocoapods-core (1.12.1)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
concurrent-ruby (~> 1.1)
Expand All @@ -54,7 +54,7 @@ GEM
netrc (~> 0.11)
cocoapods-try (1.2.0)
colored2 (3.1.2)
concurrent-ruby (1.1.10)
concurrent-ruby (1.2.2)
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
Expand All @@ -63,20 +63,20 @@ GEM
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.8.3)
i18n (1.12.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
json (2.6.2)
minitest (5.16.3)
json (2.6.3)
minitest (5.19.0)
molinillo (0.8.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
public_suffix (4.0.7)
rexml (3.2.5)
rexml (3.2.6)
ruby-macho (2.5.1)
typhoeus (1.4.0)
ethon (>= 0.9.0)
tzinfo (2.0.5)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.22.0)
CFPropertyList (>= 2.3.3, < 4.0)
Expand All @@ -85,16 +85,16 @@ GEM
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)
zeitwerk (2.6.5)
zeitwerk (2.6.11)

PLATFORMS
ruby

DEPENDENCIES
cocoapods (~> 1.11, >= 1.11.2)
cocoapods (~> 1.12)

RUBY VERSION
ruby 2.7.4p191
ruby 2.6.10p210

BUNDLED WITH
2.2.27
1.17.2
79 changes: 79 additions & 0 deletions CometChatWorkspace/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).

# Getting Started

>**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.
## Step 1: Start the Metro Server

First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native.

To start Metro, run the following command from the _root_ of your React Native project:

```bash
# using npm
npm start

# OR using Yarn
yarn start
```

## Step 2: Start your Application

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:

### For Android

```bash
# using npm
npm run android

# OR using Yarn
yarn android
```

### For iOS

```bash
# using npm
npm run ios

# OR using Yarn
yarn ios
```

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.

This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.

## Step 3: Modifying your App

Now that you have successfully run the app, let's modify it.

1. Open `App.tsx` in your text editor of choice and edit some lines.
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!

For **iOS**: Hit <kbd>Cmd ⌘</kbd> + <kbd>R</kbd> in your iOS Simulator to reload the app and see your changes!

## Congratulations! :tada:

You've successfully run and modified your React Native App. :partying_face:

### Now what?

- 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).
- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started).

# Troubleshooting

If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.

# Learn More

To learn more about React Native, take a look at the following resources:

- [React Native Website](https://reactnative.dev) - learn more about React Native.
- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.
2 changes: 1 addition & 1 deletion CometChatWorkspace/UserContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CometChat } from '@cometchat-pro/react-native-chat';
import { CometChat } from '@cometchat/chat-sdk-react-native';
import React, { createContext, useState } from 'react';

export const UserContext = createContext<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import 'react-native';
import React from 'react';
import App from '../App';

// Note: import explicitly to use the types shiped with jest.
import {it} from '@jest/globals';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

Expand Down
Loading