gpt4 book ai didi

iphone - 在一台设备上为多个用户登录 iOS 应用程序中的 Facebook

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:40:30 25 4
gpt4 key购买 nike

我的应用将被多个用户使用。

我如何以某种方式集成 facebook,以便 safari 不保存任何用户凭据并在每次有人尝试登录时抛出登录页面。

我已经使用 FBSessionLoginBehaviorForcingWebView 强制在应用程序中进行 Web View 登录,但问题是,当第一个用户尝试通过应用程序中显示的 View 登录 fb 时,控件然后转到 safari 进行身份验证 & 它只是保存信誉。

因此,当其他用户尝试登录并在应用程序本地 UIWebView 中输入他的凭据时,控件将再次转到 safari,它已经存储了以前的凭据,而新用户只是无法进行身份验证。

所以基本上第一个用户是永久登录的。清除 web View 的 cookie 不起作用。我不能为 safari 清除它们。

帮助提前致谢。

这是我一直在做的

if([FBSession activeSession].isOpen)
{
[[FBSession activeSession] closeAndClearTokenInformation];//Also, clearing all the local cookies
}
else
{
AppDelegate *delegate = [UIApplication sharedApplication].delegate;
delegate.session = [[FBSession alloc] init];
[FBSession setActiveSession:delegate.session];
[delegate.session openWithBehavior:FBSessionLoginBehaviorForcingWebView completionHandler:^(FBSession *session1, FBSessionState status, NSError *error) {
if (!error) {
[self openSession]; // your method
}
}];
}


- (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error{
switch (state) {
case FBSessionStateOpen:
{
[FBRequestConnection startForPostStatusUpdate:@"Some message"completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {

//logout again
NSLog(@"startForPostStatusUpdate SUCESS");
}
else {
//logout again
NSLog(@"startForPostStatusUpdate FAIL");
}
}];

}
break;
case FBSessionStateClosed:
{
NSLog(@"FBSessionStateClosed");
}
break;
case FBSessionStateClosedLoginFailed:
[FBSession.activeSession closeAndClearTokenInformation];
break;
default:
break;
}
if (error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
}

此外,使用您的方法修改了应用委托(delegate)。

最佳答案

找到解决方案。基本上,调用以下内容:

[FBSession.activeSession closeAndClearTokenInformation];
[FBSession.activeSession close];
[FBSession setActiveSession:nil];

只清除本地 FB session 信息,不清除 Safari cookies。因此,在我登录用户后,我清除了 Safari cookie:

NSHTTPCookie *cookie;
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies]) {
[storage deleteCookie:cookie];
}
[[NSUserDefaults standardUserDefaults] synchronize];

它不是很优雅,但它确实有效。现在,当下一个用户尝试登录时,它会强制他们输入他们的凭据。

关于iphone - 在一台设备上为多个用户登录 iOS 应用程序中的 Facebook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18827195/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com