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

查看:233
本文介绍了使用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];
    }
}

所有记录(null)。

Everything logs (null).

我认为由于行为与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天全站免登陆