Message not sent
Sometimes the message didn't saved in firebase. sendMessageWithText return Done, but in firebase, the message doesn't exist. Some of them were saved to firebase a minute later, but some of them didn't. I thought it was because something wrong and sign out, but I did try login again, but still didn't send out.
Have you made any modifications to the SDK. For example, adding your own Firebase details? Also, is there any kind of error message in the console? Finally, which country are you based in? How good is your internet connection?
Hi, I do add my own firebase info. After some debugging, I find out that it cause that user is not online. I did make some modifications to adapt to my custom login and UI, what I did is when user login to my server, I also auto login to firebase. When user open a chat room, I open up ChatSDKChatActivity directly.
Intent intent =new Intent(context, ChatSDKChatActivity.class);
From firebase, I can see sometimes once open up ChatSDKChatActivity, user "online" become true (it's working) and other time stay false (that when message will not send out). But if I log the user online property, it said user is online, in firebase, it's false. I see a lot of online checking in other activity, such as enableCheckOnlineOnResumed. I wonder it's because in the ChatSDKMainActivity, it push user online, but mine go to the ChatSDKChatActivity directly.
Thanks for your reply!!
BUser currentUser = BNetworkManager.sharedManager().getNetworkAdapter().currentUserModel();
if (currentUser.getOnline()) {
Log.e("current user", "is online");
}else {
Log.e("current user", "is not online");
}
Map<String, Object> data = AbstractNetworkAdapter.getMap(
new String[]{BDefines.Prefs.LoginTypeKey, BDefines.Prefs.LoginEmailKey, BDefines.Prefs.LoginPasswordKey},
BDefines.BAccountType.Password, email, FIRE_BASE_PASSWORD);
BNetworkManager.sharedManager().getNetworkAdapter()
.authenticateWithMap(data).done(new DoneCallback<Object>() {
@Override
public void onDone(Object o) {
BUser currentUser = BNetworkManager.sharedManager().getNetworkAdapter().currentUserModel();
Log.e("user firebase id", currentUser.getEntityID());
// 2. update user name
currentUser.setMetaName(userBean.getName());
BNetworkManager.sharedManager().getNetworkAdapter().pushUser();
}
}).fail(new FailCallback<BError>() {
@Override
public void onFail(BError bError) {
Log.e("error", "fire base login error " + bError.message);
}
});
It seem like it's not connected to firebase, goOnline or userGoOnline isn't working, I have to logout and relogin. It seem to happen when user don't have any activity for a long time (maybe 3 hours). But on my main activity, I do relogin firebase when app is open, then I open a chat room, start ChatSDKChatActivity, goOnline doesn't actually reconnect to firebase.
Map<String, Object> data = AbstractNetworkAdapter.getMap(
new String[]{BDefines.Prefs.LoginTypeKey, BDefines.Prefs.LoginEmailKey, BDefines.Prefs.LoginPasswordKey},
BDefines.BAccountType.Password, email, FIRE_BASE_PASSWORD);
BNetworkManager.sharedManager().getNetworkAdapter()
.authenticateWithMap(data).done(new DoneCallback<Object>() {
@Override
public void onDone(Object o) {
}
}).fail(new FailCallback<BError>() {
@Override
public void onFail(BError bError) {
Log.e("error", "firebase login error " + bError.message);
}
});
public void goOnline() {
DatabaseReference.goOnline();
setUserOnline();
}
@Override
protected void onStart() {
super.onStart();
getNetworkAdapter().setUserOnline();
}
@Override
protected void onStop() {
super.onStop();
getNetworkAdapter().setUserOffline();
}
help me some for my issues
I find that the problem is in login, neither success or error shown in logcat, internet connection is good, firebase database connection has not reach the limit. In BFirebaseNetworkAdapter, I also log the OnCompleteListener, both good, FirebaseAuth.getInstance().getCurrentUser() is not null. But goOnline doesn't get user connect to firebase database. I have tried many solution, but doesn't seem to work, do you have any idea @bensmiley . Thanks!
Map<String, Object> data = AbstractNetworkAdapter.getMap(
new String[]{BDefines.Prefs.LoginTypeKey, BDefines.Prefs.LoginEmailKey, BDefines.Prefs.LoginPasswordKey},
BDefines.BAccountType.Password, email, FIRE_BASE_PASSWORD);
BNetworkManager.sharedManager().getNetworkAdapter()
.authenticateWithMap(data).done(new DoneCallback<Object>() {
@Override
public void onDone(Object o) {
BUser currentUser = BNetworkManager.sharedManager().getNetworkAdapter().currentUserModel();
Log.e("error", "firebase login success user firebase id " + currentUser.getEntityID());
}
}).fail(new FailCallback<BError>() {
@Override
public void onFail(BError bError) {
Log.e("error", "firebase login error " + bError.message);
}
});
if (task.isComplete()) {
Log.e(TAG, "signInWithEmail:isComplete");
}
if (task.isSuccessful()) {
Log.e(TAG, "signInWithEmail:isSuccessful");
}
This needs to be re-tested in v4.0 and reopened if necessary.