Quickblox 会话在后台过期.如何处理? [英] Quickblox session expiration while on background. How to handle it?

查看:57
本文介绍了Quickblox 会话在后台过期.如何处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户进入后台时,我从聊天中注销用户.当用户从后台回来时,我再次在聊天中记录使用情况.

这很有效,但不是每次都有效.有时,当用户将应用程序在后台保留超过 2 小时时,会话会过期,并且当用户从后台返回时,它似乎不会自动重新验证,即使使用这段代码:

[QBSettings enableSessionExpirationAutoHandler:YES];

即使来自后台,应用程序是否应该在 enableSessionExpirationAutoHandler 开启的情况下自动重新验证会话/QB 登录?

是否有另一种方法可以在后台处理会话过期?任何人都可以给我一些建议吗?

解决方案

在最后一次向 QuickBlox 提出请求后的 2 小时内,任何会话都将保持有效.要检查会话的到期日期,请使用下一段代码:

NSDate *sessionExpiratioDate = [QBBaseModule sharedModule].tokenExpirationDate;

查看本指南 http://quickblox.com/developers/IOS#A_couple_of_words_about_Authentication_and_Authorization>

此功能从 1.8 iOS SDK 开始提供

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

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?

解决方案

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:

这篇关于Quickblox 会话在后台过期.如何处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆