CometChat Login Issue

Hi
I am having multiple apps on CometChat. Let’s name those APP1 and APP2.
After I do login into my server, I get Comet auth token from my server and then I use that token to login into comet chat.

The issue: After installing my app–>> login into my server–>> login into APP1. Till here everything works fine.

But when I use a different login and then I try to log in into APP2 then I get the following error:
2020-02-07 20:39:06.659 30363-30363/com.iosite.iositewatchapp D/LoginActivity: onError123: The auth token 5e3987bcdb660813d03d4d53_d681d63b0034388a639748418deab3f00539e58c does not exist. Please make sure you are logged in and have a valid auth token or try login again.
2020-02-07 20:39:06.659 30363-30363/com.iosite.iositewatchapp D/LoginActivity: onError456: The auth token 5e3987bcdb660813d03d4d53_d681d63b0034388a639748418deab3f00539e58c does not exist. Please make sure you are logged in and have a valid auth token or try login again.

But when I go into cometchat portal then I can find the auth token(5e3987bcdb660813d03d4d53_d681d63b0034388a639748418deab3f00539e58c) there.

Any idea as to why Cometchat is rejecting the log in???

One more query: when I log out of APP1 then I call “CometChat.logout”.
Is there any other method that I need to call to completely log out of my existing Cometchat session?

I think that I am not able to login to APP2 because the session with APP1 is not properly closed.

And please note that APP1 and APP2 are just dummy names. Basically, in which ever app i log in first it works. And after that it does not work for other apps.

My app is currently live on play/ app stores and it is creating a lot of problems for users.
Can we please get on a call to resolve this quickly?
I am available at kamran@iosite.com

Thanks
Kamran

hello @kamran_iosite
just to confirm if you are trying to log in to two separate cometchat apps in the same session for your app…?

Hi Aditya
How do you define same session?

Once i logout of first app then only i try to do init and login for second app.

How do i close a session?

Hello @kamran_iosite
Can you please share the code snippet where you logout the first app and login to the second app so that we can check this at our end…

Hi I use the below method to Logout of first APP1

    public  void doCometChatLogout() {
    CometChat.logout(new CometChat.CallbackListener<String>() {
        @Override
        public void onSuccess(String successMessage) {
            Log.d(TAG, "CometChat Logout completed successfully");
            resetTokens();
        }

        @Override
        public void onError(CometChatException e) {
            Log.d(TAG, "Logout failed with exception: " + e.getMessage());
        }
    });
}

And the below methods to login into APP2.
First i initialize cometChat by the following method:
public void setupCometChat(OnCometChatInitListener listener) {
if (!StringUtil.isNullOrEmpty(PrefUtil.getString(this, Constants.PREF_COMET_APP_ID, “”))) {
AppSettings appSettings = new AppSettings.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(Constants.REGION).build();

        Log.i(TAG, "appID in use" + PrefUtil.getString(this, Constants.PREF_COMET_APP_ID, ""));
        CometChat.init(this, PrefUtil.getString(this, Constants.PREF_COMET_APP_ID, ""), appSettings, new CometChat.CallbackListener<String>() {
            @Override
            public void onSuccess(String successMessage) {
          /*  Log.d(TAG, "Initialization completed successfully: " + successMessage);
            isCometChatloggedIn();*/
                Log.e("Manish", "Inside cometchatloggedIn" +listener );
                if (listener != null)
                    listener.onSuccess();
                //doCometChatLogout();
            }

            @Override
            public void onError(CometChatException e) {
          /*  Log.d(TAG, "Initialization failed with exception: " + e.getMessage());
            setLoginButton();*/
                if (listener != null)
                    listener.onFailed();
            }
        });
    }
}

Then i use the below method to login:
private void doCometChatLogin(final String comet_auth) {
CometChat.login(comet_auth, new CometChat.CallbackListener() {
@Override
public void onSuccess(User user) {
Log.d(TAG, "CometChat login success. UserID: " + user.getUid());
PrefUtil.putBoolean(LoginActivity.this, Constants.PREF_IS_LOGGED_IN, true);
getGroupList();
}

        @Override
        public void onError(CometChatException e) {
            e.printStackTrace();
            // TODO: need to handle the error properly. Currently its a hack.
            Log.d(TAG, "onError123: " + e.getMessage());
            if (!e.getMessage().equals("Login in progress. Please wait for the login request to finish")) {
                Log.d(TAG, "onError456: " + e.getMessage());
                setLoginButton();
            }
        }
    });
}

Thanks

1 Like

The formatting of the my last post is not proper.
Let me know if its not clear to you

Hello @kamran_iosite,
Let me check this at my end and get back to you. Can you please let us know your use case. We would like to understand as to why you need to switch between two apps in the same android application.

Hi Aditya
I am providing my app to construction companies. I need to create one cometchat app for each of my customers so that one construction company dont end up seeing messages/ contacts of other costruction company. Thats why i am creating different apps on cometchat. Let me know if there is a way better way than the one i am following.

Meanwhile, please resolve the issue asap. The app is live and customer are getting affected.

Thanks

Waiting for response.
Its urgent

Hello @kamran_iosite,
We were able to replicate this at our end… We will release a patch version with a fix for this problem in a couple of hours. We will let you know once the version is live.

1 Like

Yes please notify me asap.

Hello @kamran_iosite
We have released a new version 2.0.3-beta1 of the CometChat Pro Android SDK. We have fixed the issue mentioned by you. Please check the same at your end and let us know if everything is working as expected.

1 Like

Hi
How do i use this new version of SDK in my code?

Its working. Now i am able to login into different cometchat apps from a single device.

Just as a check: I have made the following chnages:
in build.gradle (app level)
removed:
dependencies {
** implementation ‘com.cometchat:pro-android-chat-sdk:2.0.2’**
}

and added:
dependencies {
** implementation ‘com.cometchat:pro-android-chat-sdk:2.0.3-beta1’**
}

Please confirm if that’s the only change needed.

Also, is the version “2.0.3-beta1” stable? Should I use it in production? My app is currently being used by customers.

Thanks

1 Like

hello @kamran_iosite
Yes, this version is stable. We’ve released it as a beta as it is outside our standard release cycle. We will be releasing a non-beta version next week. However, feel free to use this version in production. You should not face any issues.

1 Like

Hi @aditya.gokula,
I am also using the IOS SDK for my iphone app. Is there same problem in IOS SDK as well?

We did test the iOS SDK and everything is working as expected. You should not face this issue while using the iOS SDK.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.