Skip to content

Instantly share code, notes, and snippets.

@hieptl
Created October 10, 2021 16:19
Show Gist options
  • Save hieptl/1791b7f821afff8b940e9ad742d07998 to your computer and use it in GitHub Desktop.
Save hieptl/1791b7f821afff8b940e9ad742d07998 to your computer and use it in GitHub Desktop.
login.js - Login CometChat - React Native Gifted Chat App
...
cometChat.login(firebaseUid, `${cometChatConfig.cometChatAuthKey}`).then(
user => {
// User loged in successfully.
// save authenticated user to local storage.
AsyncStorage.setItem('auth', JSON.stringify(user));
// save authenticated user to context.
setUser(user);
// navigate to the home page
navigation.navigate('Home');
},
error => {
// User login failed, check error and take appropriate action.
setIsLoading(false);
showMessage('Error', 'Your username or password is not correct');
}
);
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment