gpt4 book ai didi

facebook - ios6 facebook 集成登录总是 FBSessionStateClosedLoginFailed 从不打开

转载 作者:行者123 更新时间:2023-11-30 05:15:32 25 4
gpt4 key购买 nike

这个问题与Facebook SDK for iOS , on iOS 4.0 device非常相似,但由于我不能在那里发表评论,所以我提出了一个新问题。我认为问题不一样:

当尝试将我的应用程序的 facebook 集成更新到 facebook 3.1 时,我没有让 facebook session 打开 sessionStateChanged 回调总是以 FBSessionStateClosedLoginFailed 结束。在我的设置中,我的 appdelegate 中有回调

- (BOOL)application:(UIApplication *)application 
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
// attempt to extract a token from the url
// return [self.session handleOpenURL:url];
return [FBSession.activeSession handleOpenURL:url];
}

但它从未被调用过!它不应该被调用吗?我按照 facebook 文档并调用

- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI {
NSArray *permissions = [NSArray arrayWithObjects:@"publish_actions", nil];
return [FBSession openActiveSessionWithPublishPermissions:permissions
defaultAudience:FBSessionDefaultAudienceFriends
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
[self sessionStateChanged:session
state:state
error:error];
}];
}

我也试过

openActiveSessionWithReadPermissionsnil 的权限,如 facebook 教程示例中所示,目的是稍后重新授权 publish_actions 权限。同样的结果:FBSessionStateClosedLoginFailed 再次失败。

我什至试过打电话

ACAccountStore *accountStore;
ACAccountType *accountTypeFB;
if ((accountStore = [[ACAccountStore alloc] init]) &&
(accountTypeFB = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook] ) ){

NSArray *fbAccounts = [accountStore accountsWithAccountType:accountTypeFB];
id account;
if (fbAccounts && [fbAccounts count] > 0 &&
(account = [fbAccounts objectAtIndex:0])){

[accountStore renewCredentialsForAccount:account completion:^(ACAccountCredentialRenewResult renewResult, NSError *error) {
//we don't actually need to inspect renewResult or error.
if (error){

}
}];
}
}

在尝试打开 session 之前,但我从未在我的 ios6 设备 (iphone 4s) 上打开它。在应用程序中,我被要求获得许可,但随后没有任何进展,因为 session 始终处于 FBSessionStateClosedLoginFailed 状态!我对 session 状态的回调是

- (void)sessionStateChanged:(FBSession *)session
state:(FBSessionState) state
error:(NSError *)error
{
switch (state) {
case FBSessionStateOpen:
if (!error) {
// We have a valid session
NSLog(@"User session found");
}
break;
case FBSessionStateClosed:
NSLog(@"FBSessionStateClosed");
case FBSessionStateClosedLoginFailed:
NSLog(@"FBSessionStateClosedLoginFailed");
[FBSession.activeSession closeAndClearTokenInformation];
break;
default:
break;
}

[[NSNotificationCenter defaultCenter]
postNotificationName:FBSessionStateChangedNotification
object:session];

if (error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"facebook Hinweis"
message:@"facebook Login nicht möglich, bitte versuchen Sie es erneut."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
NSLog(@"Facebook session error: %@", error.localizedDescription);
}
}

在 ios 5 上使用 facebook 3.0 我从来没有遇到过问题,所以我的 facebook 应用程序设置正确。我真的很感激任何帮助我打开 facebook session 的帮助,没想到 facebook 3.1 会遇到这些问题,而且文档在这一点上没有帮助我,thx

最佳答案

我遇到了同样的问题,是因为我忘了实现

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
return [FBSession.activeSession handleOpenURL:url];
}

在我的 AppDelegate 中

关于facebook - ios6 facebook 集成登录总是 FBSessionStateClosedLoginFailed 从不打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12661104/

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