iPhone / iOS版的Facebook SDK - 你可以在应用程序内登录,并保留登录凭据? [英] iPhone / iOS Facebook SDK - can you log in within the app, and keep the login credentials?

查看:94
本文介绍了iPhone / iOS版的Facebook SDK - 你可以在应用程序内登录,并保留登录凭据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能使用Facebook的iOS SDK(不去Safari浏览器)应用程序中进行身份验证,同时也让那些认证证书在未来推出的应用程序?

Is it possible to use the Facebook iOS SDK to authenticate within an app (not go to Safari), and also keep those authentication credentials for the next launch of the app?

当我尝试使用演示应用程序在模拟器中,它总是去到Safari进行身份验证,这似乎有点蹩脚。然后,当我进行身份验证...如果我完全杀死应用程序,它会问再次认证(然后告诉我,我已经登录)

When I try to use the demo app in the simulator, it always goes to safari to authenticate, which seems a bit crappy. And then, when I authenticate... if I completely kill the app it will ask to authenticate again (and then tell me I am already logged in)

有没有办法,只是present只有一个电子邮件字段和密码字段,然后用户保持该信息..在应用程序内?

Is there a way, to just present the user with just an email field and a password field and then keep that info.. within the app?

推荐答案

看看这个问题,答案是:<一href=\"http://stackoverflow.com/questions/4501774/iphone-facebook-connect-example-calls-safari-i-dont-want-use-safari/4501845#4501845\">http://stackoverflow.com/questions/4501774/iphone-facebook-connect-example-calls-safari-i-dont-want-use-safari/4501845#4501845.另外,你要验证的东西存放在 NSUserDefaults的,并检查他们做出prevent重新登录。

Take a look at this question and answer: http://stackoverflow.com/questions/4501774/iphone-facebook-connect-example-calls-safari-i-dont-want-use-safari/4501845#4501845. Also, you'll want to store the authentication stuff in NSUserDefaults and check for them to make to prevent re-logins.

修改一些示例code:

要保存登录的东西:

[[NSUserDefaults standardUserDefaults] setObject:_facebook.accessToken forKey:@"AccessToken"];
[[NSUserDefaults standardUserDefaults] setObject:_facebook.expirationDate forKey:@"ExpirationDate"];
[[NSUserDefaults standardUserDefaults] synchronize];

要检查登录的东西:

_facebook = [[[Facebook alloc] initWithAppId:@"[app_id]"] retain];
_facebook.accessToken    = [[NSUserDefaults standardUserDefaults] stringForKey:@"AccessToken"];
_facebook.expirationDate = (NSDate *) [[NSUserDefaults standardUserDefaults] objectForKey:@"ExpirationDate"];
if (![_facebook isSessionValid]) {
    [_facebook authorize:_permissions delegate:self];
}
else {
    [_facebook requestWithGraphPath:@"me" andDelegate:self];
}

这篇关于iPhone / iOS版的Facebook SDK - 你可以在应用程序内登录,并保留登录凭据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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