使用 Parse iOS 登录 Facebook 和 twitter 只能使用一次 [英] Facebook and twitter login with Parse iOS only works once

查看:21
本文介绍了使用 Parse iOS 登录 Facebook 和 twitter 只能使用一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Parse SDK 中使用 twitter 和 Facebook 登录.对于每次应用程序启动,我可以登录每个服务一次,但是当我使用 [PFUser logOut] 注销时,我无法再次登录.[PFFacebookUtils logInWithPermissions] 块永远不会被用户或错误调用.

I'm using the twitter and Facebook login in the Parse SDK. For every app launch I can log into each service once, but when I logout using [PFUser logOut] I am unable to log in again. The [PFFacebookUtils logInWithPermissions] block never gets called either with a user or an error.

我的 (Facebook) 登录代码是:

My (Facebook) Login Code is:

- (IBAction)facebookLogin:(id)sender {
    NSArray *permissionsArray = @[ @"user_about_me" ];

    // Login PFUser using Facebook
    [PFFacebookUtils logInWithPermissions:permissionsArray block:^(PFUser *user, NSError *error) {
        if (!user) {
            NSString *errorMessage = nil;
            if (!error) {
                NSLog(@"Uh oh. The user cancelled the Facebook login.");
                errorMessage = @"Uh oh. The user cancelled the Facebook login.";
            } else {
                NSLog(@"Uh oh. An error occurred: %@", error);
                errorMessage = [error localizedDescription];
            }
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Log In Error"
                                                            message:errorMessage
                                                           delegate:nil
                                                  cancelButtonTitle:nil
                                                  otherButtonTitles:@"Dismiss", nil];
            [alert show];
        } else {
            if (user.isNew) {
                NSLog(@"User with facebook signed up and logged in!");
            } else {
                NSLog(@"User with facebook logged in!");
            }
        }
    }];
}

我的登出代码是:

- (IBAction)loginButton:(id)sender {
    if([PFUser currentUser]) {
        [PFUser logOut];        
        NSLog(@"User is %@", [PFUser currentUser]);
        NSLog(@"Facebook session is %@", [PFFacebookUtils session]);
        NSLog(@"Facebook session is %@", FBSession.activeSession.observationInfo);
    } else {
        [self performSegueWithIdentifier:@"loginScreenSegue" sender:self];
    }
}

一切记录(空).

我假设由于行为与 Twitter 相同,它可能与我的 AppDelegate 中的 OAuth 相关方法有关:

I assumed that as the behaviour was the same with Twitter, that it might be related to the OAuth related methods in my AppDelegate:

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
         annotation:(id)annotation {
    return [FBAppCall handleOpenURL:url
                  sourceApplication:sourceApplication
                        withSession:[PFFacebookUtils session]];
}

- (BOOL) application:(UIApplication *)application
       handleOpenURL:(NSURL *)url
   sourceApplication:(NSString *)sourceApplication
          annotation:(id)annotation {
    return [FBAppCall handleOpenURL:url
                  sourceApplication:sourceApplication
                        withSession:[PFFacebookUtils session]];
}

但是已经做了很多研究,似乎没有遗漏任何东西......

But have done a lot of research and don't seem to be missing anything...

我在 AppDelegate 中也有这些:

I also have these in the AppDelegate:

- (void)applicationWillResignActive:(UIApplication *)application {
    [[PFFacebookUtils session] close];
}

- (void)applicationWillTerminate:(UIApplication *)application {
    [[PFFacebookUtils session] close];
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    [FBAppCall handleDidBecomeActiveWithSession:[PFFacebookUtils session]];
}

非常感谢您的帮助!

推荐答案

好的,我终于解决了这个问题.问题是,在我在 twitter 上设置的应用程序中,权限设置为只读",而不是读取和写入".

OK, I finally solved this. The problem was that in my app setup on twitter, the permissions were set to 'Read only', not 'Read and Write'.

更改此设置解决了 facebook 和 twitter 的问题.

Changing this setting solved the problem with both facebook and twitter.

这篇关于使用 Parse iOS 登录 Facebook 和 twitter 只能使用一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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