Closed karthiciist closed 5 years ago
At the moment ChatManager doesn't support Google SignIn. See ChatAuthentication class for extension.
How can we add Google and Facebook login with this library? Can you suggest where should we start if we want to integrate?
This SDK actually uses iChatUser object to initialize the chat. This object will be created by using the user name provided during login. If we need to use google signin, we need to pass "FirebaseUser currentUser" object to create iChatUser object. Put this code in your AppContext class:
public void initChatSDK() {
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
ChatManager.Configuration mChatConfiguration =
new ChatManager.Configuration.Builder(getString(R.string.chat_firebase_appId))
.firebaseUrl("https://xyz.firebaseio.com/")
.storageBucket("gs://xyz.appspot.com")
.build();
FirebaseUser currentUser = FirebaseAuth.getInstance().getCurrentUser();
if (currentUser != null) {
IChatUser iChatUser = (IChatUser) IOUtils.getObjectFromFile(instance,
_SERIALIZED_CHAT_CONFIGURATION_LOGGED_USER);
ChatManager.start(this, mChatConfiguration, iChatUser);
Log.i(TAG, "chat has been initialized with success");
ChatUI.getInstance().setContext(instance);
ChatUI.getInstance().enableGroups(true);
ChatUI.getInstance().setOnMessageClickListener(new OnMessageClickListener() {
@Override
public void onMessageLinkClick(TextView message, ClickableSpan clickableSpan) {
String text = ((URLSpan) clickableSpan).getURL();
Uri uri = Uri.parse(text);
Intent browserIntent = new Intent(Intent.ACTION_VIEW, uri);
browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(browserIntent);
}
});
final IChatUser support = null;
ChatUI.getInstance().setOnNewConversationClickListener(new OnNewConversationClickListener() {
@Override
public void onNewConversationClicked() {
if (support != null) {
ChatUI.getInstance().openConversationMessagesActivity(support);
} else {
Intent intent = new Intent(instance, ContactListActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // start activity from context
startActivity(intent);
}
}
});
Log.i(TAG, "ChatUI has been initialized with success");
} else {
Log.w(TAG, "chat can't be initialized because chatUser is null");
}
}
My app uses google signin from firebase. How to pass user password to the following code :
ChatManager.startWithEmailAndPassword(this, getString(R.string.google_app_id), "john@nashville.it", "123456", new ChatAuthentication.OnChatLoginCallback() {...........