我已阅读了大量有关ACAccounts.framework
此应用程序的信息并将其成功集成到我的应用程序中。
老实说,所有这些教程都没有很好的错误流程以及下一步该怎么做。
我的以下身份验证工作正常:
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSDictionary *options = @{
ACFacebookAppIdKey : kPSFacebookKey,
ACFacebookPermissionsKey : @[@"email"],
ACFacebookAudienceKey : ACFacebookAudienceEveryone};
[accountStore requestAccessToAccountsWithType:accountType
options:options
completion:^(BOOL granted, NSError *error){
if (granted) {
NSArray *accounts = [_currentUser.accountStore
accountsWithAccountType:accountType];
_currentUser.facebook = [accounts firstObject];
dispatch_async(dispatch_get_main_queue(), ^{
authSuccess();
});
} else {
dispatch_async(dispatch_get_main_queue(), ^{
authFailure(error);
// Display UIAlertView to make user go to settings and add account?! WHAT?
});
}
}];
如果用户在设置中具有帐户,而我依靠该帐户并认为该用户已登录。
这确实可以按预期工作,但只要获得批准,只要用户在中拥有帐户即可settings
。否则,我会显示警报以使用户转到settings
并添加帐户。我不要那样!
因此,所需的流程是:
settings
通过ACAccountStore
WORKS提取帐户的帐户settings
->转到facebook
应用程序?facebook
应用程序->转到safari
facebook
登录表单->登录,然后返回到应用程序我相信Foursquare
有这样的流程。
所以我的主要问题是:
Facebook iOS SDK
Facebook
会话中的凭据并将其ACAccountStore
手动添加吗?谢谢
我遇到了这个gist
:
https://gist.github.com/rsms/4726728
满足以下期望:
settings
通过提取的帐户ACAccountStore
settings
->转到Facebook应用Facebook
应用程序->进入safari
Facebook
登录表单->输入凭据->自动返回到应用程序真正很酷的是,我不必手动获取ACAccountStore
(iOS系统中的帐户),Facebook SDK可以帮我实现,而我仅依靠Facebook会话(isOpen)。
仍然存在一个问题,就是会话在重新启动应用程序后消失了,这可以通过添加以下方法解决:
[FBSession openActiveSessionWithReadPermissions:nil
allowLoginUI:NO
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {}];
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句