user3344977 user3344977 - 3 months ago 14x
iOS Question

Forced to create a new Quickblox session every time iOS app is opened

I am using the

Quickblox iOS SDK 2.0.12

I have been following the instructions on Quickblox Authentication and Authorization here.

I call
QBRequest createSessionWithSuccessBlock:
, and then call
QBRequest signUp:
inside it's completion block, and then I call
QBRequest logInWithUserLogin:
inside the next completion block.

According to the above link, I should now have a
Quickblox User Session
after doing all of this. This all works perfectly and all of the calls are successful and I can see that the user is now in the
Quickblox Admin Panel

After doing this, if I make
requests they work fine. The only weird thing is that
[[QBSession currentSession] currentUser]

Anyways, if I stop running the app on the simulator, and then run the app again 10 minutes later, I check for persisted custom data so I can see if the user has already signed up or not. When the user has signed up, then I take them into the app instead of them needing to signup or login again.

Now, if I try to make any requests to
, 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's saying I need to create a session when I already just created one when the user first signed up. I understand that the session expires every 2 hours, but I am testing this very quickly and I am always receiving this error.

If I
[QBSession currentSession]
I can see that there is currently a
object, but if I try to
any of it's properties like
, or
they all log as


As I know, only if you use this method - (void)startSessionForUser:(QBUUser *)user withDetails:(QBASession *)session expirationDate:(NSDate *)sessionDate , you can use this property correct. But I didn't ever use it.

For recreating a session I use [QBConnection setAutoCreateSessionEnabled:YES] and for chat I keep QBUUser in my Manager, and after entering foreground I check XMPP connection [[QBChat instance] isLoggedIn]. Maybee it may help you.