Skip to content

Instantly share code, notes, and snippets.

@hieptl
Last active October 18, 2021 13:43
Show Gist options
  • Save hieptl/71fbbd3c582b58465587e79fc70e181c to your computer and use it in GitHub Desktop.
Save hieptl/71fbbd3c582b58465587e79fc70e181c to your computer and use it in GitHub Desktop.
App.tsx - Initialize CometChat - Ionic Chat App
...
useEffect(() => {
initCometChat();
...
}, []);
...
const initCometChat = async () => {
const { CometChat } = await import('@cometchat-pro/cordova-ionic-chat');
const appID = `${process.env.REACT_APP_COMETCHAT_APP_ID}`;
const region = `${process.env.REACT_APP_COMETCHAT_REGION}`;
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