3

When the user goes to background, I log out the user from chat. When the user comes back from background, I log the use again in chat.

This works well but not every time. Sometimes when the user keeps the app more then 2 hours in background, the session expires and it doesn't seem to revalidate automatically when the user comes back from background, even with this piece of code:

[QBSettings enableSessionExpirationAutoHandler:YES];

Should the app revalidate the session/QB login automatically with enableSessionExpirationAutoHandler on even when coming from background?

Is there another way to handle session expiration while in background? Can anyone please suggest me some ideas?

MusicLovingIndianGirl
  • 5,909
  • 9
  • 34
  • 65
Mario Frade
  • 273
  • 1
  • 2
  • 11

1 Answers1

1

Any session will remain valid for 2 hours after the last request to QuickBlox. To check a session's expiration date use this next snippet of code:

NSDate *sessionExpiratioDate = [QBBaseModule sharedModule].tokenExpirationDate;

Check this guide http://quickblox.com/developers/IOS#A_couple_of_words_about_Authentication_and_Authorization

This feature is available since 1.8 iOS SDK

http://quickblox.com/developers/IOS#Framework_changelog:

Rubycon
  • 18,156
  • 10
  • 49
  • 70
  • 1
    Thanks Igor, but what I would like to know is if [QBSettings enableSessionExpirationAutoHandler:YES]; is enough or do I need to manage session expiration? – Mario Frade Jan 21 '14 at 12:40
  • You can use it, but this an old and undocumented feature and could be changed in future. I recommend to manually manage session expiration. For example do this each time in delegate method applicationWillEnterForeground – Rubycon Jan 21 '14 at 12:46
  • Thanks. Will do that. – Mario Frade Jan 21 '14 at 13:37