Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@tencentcloud/chat-uikit-react-native
Advanced tools
Build In-App Chat & Audio/Video Call & Live Streaming in minutes with UIKit components for react-native.
chat-uikit-react-native is a React Native UI component library based on Tencent Cloud Chat SDK. It provides universally used UI components that include ConversationList, Chat, and Group components. Leveraging these meticulously crafted UI components, you can quickly construct an elegant, reliable, and scalable Chat application.
In respect for the copyright of the emoji design, the Chat Demo/TUIKit project does not include the cutouts of large emoji elements. Please replace them with your own designed or copyrighted emoji packs before the official launch for commercial use. The default small yellow face emoji pack is copyrighted by Tencent Cloud and can be authorized for a fee. If you wish to obtain authorization, please submit a ticket to contact us.
This section shows the prerequisites you need to check to use @tencentcloud/chat-uikit-react-native
.
More details, please see https://reactnative.dev/docs/environment-setup
This section gives you information you need to get started with chat-uikit-react-native.
You can get started by creating a project with react-native 0.75.0
. (highly recommended to use typescript)
npx @react-native-community/cli@latest init ChatApp --version 0.75.0
Navigate to the app directory
cd ChatApp
chat-uikit-react-native can be installed through either yarn
or npm
npm install @tencentcloud/chat-uikit-react-native
yarn add @tencentcloud/chat-uikit-react-native
npm install react-native-image-picker react-native-document-picker react-native-video
yarn add react-native-image-picker react-native-document-picker react-native-video
Client apps must acquire permission from users to get access to their media library and save files to their mobile storage. Once the permission is granted, users can send images and videos to other users and save media files.
Add the following permissions to your android/app/src/main/AndroidManifest.xml
file.
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Add the following permission usage descriptions to your info.plist
file.
<key>NSCameraUsageDescription</key>
<string> we would like to use your camera</string>
<key>NSPhotoLibraryUsageDescription</key>
<string> we would like to use your photo library</string>
<key>NSMicrophoneUsageDescription</key>
<string>we would like to use your microphone</string>
Now you can use TUILogin
login to chat-uikit-react-native
.
The options
parameter is of the Object
type. It contains the following attribute values:
Name | Type | Description |
---|---|---|
SDKAppID | number | Required, SDKAppID of the chat app |
userID | string | Required, user ID |
userSig | string | Required, the password with which the user logs in to the Chat console. It is essentially the ciphertext generated by encrypting information such as the UserID. For the detailed generation method, see Generating UserSig |
useUploadPlugin | boolean | Optional, whether to use the upload plugin, the default is false |
framework | string | undefined | Required, UI framework type, optional values: rn 、undefined |
import { TUILogin } from '@tencentcloud/tui-core';
TUILogin.login(options);
Now you can create a screen and integrate it with a navigation library like react-navigation.
react-navigation can be installed through either yarn
or npm
npm install @react-navigation/native react-native-screens react-native-safe-area-context @react-navigation/native-stack
yarn add @react-navigation/native react-native-screens react-native-safe-area-context @react-navigation/native-stack
The example below shows how to integrate using react-navigation
.
Create a new Screens.tsx
in the same directory as App.tsx
.
import React from 'react';
import { useNavigation } from '@react-navigation/native';
import { ConversationList, Chat, ChatSetting } from '@tencentcloud/chat-uikit-react-native';
export const ConversationListScreen = () => {
const navigation = useNavigation<any>();
const onPressConversation = () => {
navigation.navigate('Chat');
};
return (
<ConversationList onPressConversation={onPressConversation} />
);
};
export const ChatScreen = () => {
const navigation = useNavigation<any>();
const navigateBack = () => {
navigation.goBack();
};
const navigateToChatSetting = () => {
navigation.navigate('ChatSetting');
};
return (
<Chat
navigateBack={navigateBack}
navigateToChatSetting={navigateToChatSetting}
/>
);
};
export const ChatSettingScreen = () => {
const navigation = useNavigation<any>();
// Navigate to Chat when you click header back button.
const navigateBack = () => {
navigation.goBack();
};
// Navigate to Chat when you click the send message button.
const navigateToChat = () => {
navigation.goBack();
};
// Navigate to ConversationList when you disband group or leave group.
const navigateToConversationList = () => {
navigation.navigate('ConversationList');
};
return (
<ChatSetting
navigateBack={navigateBack}
navigateToChat={navigateToChat}
navigateToConversationList={navigateToConversationList}
/>
);
};
import React from 'react';
import {
View,
TouchableOpacity,
Text,
Image,
StyleSheet,
} from 'react-native';
import { NavigationContainer, useNavigation } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { UIKitProvider } from '@tencentcloud/chat-uikit-react-native';
import resources from '@tencentcloud/chat-uikit-react-native/i18n';
import { TUITranslateService } from '@tencentcloud/chat-uikit-engine';
import { TUILogin } from '@tencentcloud/tui-core';
import { ConversationListScreen, ChatScreen, ChatSettingScreen } from './Screens';
const LoginScreen = () => {
const navigation = useNavigation<any>();
// Init localization
TUITranslateService.provideLanguages(resources);
TUITranslateService.useI18n('en-US');
// Login
const Login = () => {
TUILogin.login({
SDKAppID: 0,
userID: '',
userSig: '',
useUploadPlugin: true,
framework: 'rn',
}).then(() => {
navigation.navigate('ConversationList');
});
}
return (
<View style={styles.container}>
<Image
style={styles.logo}
source={{uri:'https://web.sdk.qcloud.com/im/assets/images/tencent_rtc_logo.png'}}
/>
<TouchableOpacity style={styles.buttonContainer} onPress={Login}>
<Text style={styles.buttonText}>Log in</Text>
</TouchableOpacity>
</View>
);
};
const Navigation = () => {
const Stack = createNativeStackNavigator();
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={{ headerShown: false }}
initialRouteName="Login">
<Stack.Screen
name="Login"
component={LoginScreen} />
<Stack.Screen
name="ConversationList"
component={ConversationListScreen} />
<Stack.Screen
name="Chat"
component={ChatScreen} />
<Stack.Screen
name="ChatSetting"
component={ChatSettingScreen}/>
</Stack.Navigator>
</NavigationContainer>
);
};
const App = () => {
return (
<UIKitProvider>
<Navigation />
</UIKitProvider>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#FFFFFF',
},
logo: {
width: 232,
height: 80,
},
buttonContainer: {
width: '80%',
justifyContent: 'center',
alignItems: 'center',
paddingVertical: 11,
borderRadius: 5,
backgroundColor: '#2F80ED',
},
buttonText: {
fontSize: 18,
lineHeight: 24,
color: '#FFFFFF',
},
});
export default App;
To compile and run the project, you need to use a real device or an emulator.A real device is recommended. You can refer to the React Native official website running-on-device to connect a real device for debugging.
npm run android
yarn android
npm run ios
yarn ios
FAQs
Build In-App Chat & Audio/Video Call & Live Streaming in minutes with UIKit components for react-native.
We found that @tencentcloud/chat-uikit-react-native demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.