Closed richanshah closed 6 months ago
i found issue.
@tatanka987 , i am getting same issue with register in demo app too.
REQUEST POST https://api.connectycube.com/session HEADERS {Content-type: application/json, ConnectyCube-REST-API-Version: 0.1.1, CB-SDK: Flutter 2.6.0, CB-Token: } BODY {"application_id":"7254","auth_key":"gab3wNneRF-mjS2","nonce":"1768202510","timestamp":"1692191614","signature":"6a7d11add118accad8ef5708920587ef22cc4527","user":{"login":"share","password":"123456"}}
{"errors":["User not found"]}
are you sure that you have the user with login share
in your app? you should create a user first then use it for session creation.
if (!CubeSessionManager.instance.isActiveSessionValid()) { try { await createSession(); } catch (error) { _processLoginError(error); } } my this condition is getting true , I dont know why so it is going to create session even in signup
before signup, the empty session (without a user) should be created
okay thanks
looks like you set the user in the callback onSessionRestore
before it signup on the Connectycube. the SDK requires a session and tries to create one using this callback but you set there unregistered user. Can it be?
onSessionRestore: () async { DebugLog.e('onSessionRestore: ');
if (ChatLoginType.phone == SharedPref.getLoginType()) {
return createPhoneAuthSession();
}
DebugLog.d("onSessionRestore: ${SharedPref.getUser()?.login.toString()}");
if (SharedPref.getUser()?.login != null) {
return createSession(SharedPref.getUser());
}
return Future(() => throw Exception("User is null"));
i have commented this code because i was getting some issues but now it is working, my signup flow completed thanks for the help
if you don't have a saved user you should return an empty session from this callback, but pay attention - you should save the user only after success signup
this is my logout code.
/// Logout from connectyCube void logoutFromConnectyCube() async { signOut().then( (voidValue) { DebugLog.d('Logout void from connectyCube'); Get.back(); // cancel current Dialog }, ).catchError( (onError) { DebugLog.d('Logout error from connectyCube$onError'); Get.back(); // cancel current Dialog }, ).whenComplete(() { DebugLog.d('Logout from connectyCube'); CubeChatConnection.instance.destroy(); PushNotificationsManager.instance.unsubscribe(); FirebaseAuth.instance.currentUser?.unlink(PhoneAuthProvider.PROVIDER_ID); // SharedPref.deleteUser(); }); } }
this is is when i logout it is going to on session restore . is there any way to restrict when i logout it should not go to session restore right?
12:10:37.907 I [38;5;196monSessionRestore: [0m
12:10:37.911 I onSessionRestore:
12:10:37.953 I CB-SDK: : =========================================================
12:10:37.954 I === REQUEST ==== 83cb18c3-7b8c-4bf3-b978-11e41a847296 ===
12:10:37.954 I REQUEST
12:10:37.954 I POST https://api.connectycube.com/session
12:10:37.954 I HEADERS
12:10:37.954 I {Content-type: application/json, ConnectyCube-REST-API-Version: 0.1.1, CB-SDK: Flutter 2.7.0, CB-Token: }
12:10:37.954 I BODY
12:10:37.954 I {"application_id":"7266","auth_key":"cKYHfvnvsHqX6JX","nonce":"1146102762","timestamp":"1692254437","signature":"d97797c342bc8b152c75ff0c913d916c57daa0b6","user":{"login":"","email":"","password":""}}
12:10:37.954 I
12:10:38.355 I _getNativeFcmToken
12:10:38.355 I fJdUP_PPRTW1oCpJIj86H-:APA91bEvlHoTl9LJbgQsDyegvObFyAEJDxspcOkg9LI472joIe1Y2xupZxIGl9829mSUbcxW6RNzU_jyb7NC89niiq-SGFPnR6t9zhH7QhnlZVZYpD5y4suFC3nW1or-eZ6cJPNpieQf
12:10:39.348 I CB-SDK: : ***
12:10:39.348 I * RESPONSE 422 83cb18c3-7b8c-4bf3-b978-11e41a847296 ***
12:10:39.348 I HEADERS
12:10:39.348 I {connection: keep-alive, date: Thu, 17 Aug 2023 06:40:39 GMT, content-length: 61, strict-transport-security: max-age=15768000; includeSubDomains, access-control-expose-headers: CB-Token-ExpirationDate, Date, content-type: application/json; charset=utf-8, server: nginx/1.25.0}
12:10:39.348 I BODY
12:10:39.348 I {"errors":{"user.login":["user login or email is required"]}}
12:10:39.348 I
12:10:39.351 I Logout error from connectyCubeResponseException: 422: {"errors":{"user.login":["user login or email is required"]}}
12:10:39.355 I Logout from connectyCube
12:10:39.356 I CB-SDK: CubeChatConnection: [destroy]
12:10:39.358 I CB-SDK: CubeChatConnection: [logout]
12:10:39.366 I CB-SDK: CubeChatConnection: [_clearConnection]
or is it right way as per my logs? what is ur opinion
@TatankaConCube , can u send me notification json format response ? for both kind of notification coming from dashboard and from one app to another app ?
do you mean the notification payload? or what?
please create different tasks per topic. it will help other users to find the answers to their questions.
is there any way to restrict when i logout it should not go to session restore right?
yes, you should skip the signOut()
if you don't have a valid session and perform the code from the whenComplete
callback at once. but pay attention, to performing the PushNotificationsManager.instance.unsubscribe();
method you need to have a valid session with the user.
and delete the saved user after performing all signout steps
do you mean the notification payload? or what?
yes
please create different tasks per topic. it will help other users to find the answers to their questions.
noted
do you mean the notification payload? or what?
yes
sorry, but the back-end team can't provide me this info((( you can print it to the console log after receiving the push notification on the receiver side. also, you can get acquainted with some platform-specific parameters in the Server API documentation
hello , i have created new app with new credentials for my app. i am trying to register user but getting below error. could u help to find reason ?
I/flutter (23933): CB-SDK: : ========================================================= I/flutter (23933): === REQUEST ==== e831b92c-1884-49fe-965f-ef4fd4b0e9ad === I/flutter (23933): REQUEST I/flutter (23933): POST https://api.connectycube.com/session I/flutter (23933): HEADERS I/flutter (23933): {Content-type: application/json, ConnectyCube-REST-API-Version: 0.1.1, CB-SDK: Flutter 2.7.0, CB-Token: } I/flutter (23933): BODY I/flutter (23933): {"application_id":"7266","auth_key":"cKYHfvnvsHqX6JX","nonce":"571803620","timestamp":"1692187098","signature":"33d915d7ad038e26d3645f9475fc292995f86bc7","user":{"login":"richaa","email":"shah11@gmail.com","password":"123456"}} I/flutter (23933): I/flutter (23933): CB-SDK: : *** I/flutter (23933): * RESPONSE 404 e831b92c-1884-49fe-965f-ef4fd4b0e9ad *** I/flutter (23933): HEADERS I/flutter (23933): {connection: keep-alive, content-type: application/json; charset=utf-8, date: Wed, 16 Aug 2023 11:58:20 GMT, strict-transport-security: max-age=15768000; includeSubDomains, server: nginx/1.25.0, content-length: 29} I/flutter (23933): BODY I/flutter (23933): {"errors":["User not found"]}