简体   繁体   English

当应用退出时,Facebook SDK iOS应用保持登录状态

[英]Facebook SDK iOS app stay logged in when app quits

Currently I'm using the below if statement to check if the user has an open session to facebook through my app. 目前,我正在使用以下if语句来检查用户是否通过我的应用打开了与Facebook的公开会话。

if (FBSession.activeSession.isOpen) {
     // post to wall
}
else {
     [appDelegate openSessionWithAllowLoginUI:YES];
}

If the user quits the app then the session is closed and my if statement opens a new session, however I would like to keep the session open even if the user quits the app. 如果用户退出了该应用程序,则该会话将关闭,而我的if语句将打开一个新会话,但是即使用户退出了该应用程序,我也希望保持该会话为打开状态。

I tried removing [FBSession.activeSession close] from applicationWillTerminate: however this didn't work. 我尝试从applicationWillTerminate:删除[FBSession.activeSession close] applicationWillTerminate:但是,这没有用。

You can't logout fully. 您无法完全注销。 but you can clear all detail of last session by below code. 但是您可以通过以下代码清除上次会话的所有详细信息。

[FBSession.activeSession closeAndClearTokenInformation];

you can write it according to your requirement either in applicationDidEnterBackground or applicationWillTerminate. 您可以根据需要在applicationDidEnterBackground或applicationWillTerminate中编写它。

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM