Skip to content

Instantly share code, notes, and snippets.

@hieptl
Last active October 12, 2021 09:12
Show Gist options
  • Save hieptl/1a57370fa879583e8cf3197198115489 to your computer and use it in GitHub Desktop.
Save hieptl/1a57370fa879583e8cf3197198115489 to your computer and use it in GitHub Desktop.
App.js - Init CometChat - React Native Gifted Chat App
...
useEffect(() => {
initCometChat();
...
}, []);
const initCometChat = async () => {
const { CometChat } = await import('@cometchat-pro/react-native-chat');
const appID = `${cometChatConfig.cometChatAppId}`;
const region = `${cometChatConfig.cometChatRegion}`;
const appSetting = new CometChat.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(region).build();
CometChat.init(appID, appSetting).then(
() => {
console.log('CometChat was initialized successfully');
setCometChat(() => CometChat);
},
error => {
}
);
};
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment