Force a new Quickblox session to be created every time the iOS app opens
I use Quickblox iOS SDK 2.0.12
I followed the Quickblox Authentication and Authorization instructions here .
I call QBRequest createSessionWithSuccessBlock:
and then call QBRequest signUp:
inside the completion block and then call QBRequest logInWithUserLogin:
inside the next completion block.
As per the above link, I should now have Quickblox User Session
after doing all this. This all works fine and all calls are successful and I see that the user is now in Quickblox Admin Panel
.
After that, if I make requests Quickblox
, they work fine. The only strange thing is [[QBSession currentSession] currentUser]
NSLogs
how (null)
.
Anyway, if I stop running the application on the simulator and then start the application again after 10 minutes, I will check the saved user data so that I can see if the user was already logged in or not. When a user signs up, I take them to the app instead of having to sign up or sign in again.
Now if I try to execute any requests to Quickblox
, I get the following exception:
Terminating app due to uncaught exception 'BaseServiceException', reason: 'You have missed the authorization call.
Please insert following code inside your application
[QBRequest createSessionWithSuccessBlock:errorBlock:];
Before any other code, that uses our service, but after setup credentials. Thank you.'
I don't understand why it says I need to create a session when I already created it when the user first logged in. I understand that the session expires every 2 hours, but I am testing this very quickly and I always get this error.
If I NSLog
[QBSession currentSession]
, I can see that the object currently exists QBSession
, but if I try to NSLog
execute any of its properties such as sessionDetails
, sessionExpirationDate
or currentUser
, they all register as (null)
.
source to share
As I know, only if you use this method - (void)startSessionForUser:(QBUUser *)user withDetails:(QBASession *)session expirationDate:(NSDate *)sessionDate
can you use this property correctly. But I have never used it.
To recreate the session I use [QBConnection setAutoCreateSessionEnabled:YES]
, and for chat I keep the QBUUser in my Manager and after typing in the foreground I check the XMPP connection [[QBChat instance] isLoggedIn]
. Maybee can help you.
source to share