gpt4 book ai didi

ios - 通过 Safari 或 FB App 登录 Facebook 无效

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:37:53 25 4
gpt4 key购买 nike

当用户在 iOS8 设置中登录 Facebook 时,此方法非常有效。

但如果他没有,它会尝试使用 Safari 或 Facebook iOS 应用程序登录,一旦用户被重定向回应用程序,它只会显示这条记录的消息,而不是让用户登录。

我正在使用 Parse.com SDK。

消息已记录

NSLog(@"Uh oh. The user cancelled the Facebook login.");

Facebook 登录方法

-(void)loginButtonPressed
{
[PFFacebookUtils initializeFacebook];

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) {
[self dismissViewControllerAnimated:YES completion:nil];

NSLog(@"User with facebook signed up and logged in!");
} else {
[self dismissViewControllerAnimated:YES completion:nil];

NSLog(@"User with facebook logged in!");
}
// [self _presentUserDetailsViewControllerAnimated:YES];
}];

}

最佳答案

AppDelegate.m 中添加这一行解决了这个问题。

- (void)applicationDidBecomeActive:(UIApplication *)application {

[FBAppCall handleDidBecomeActiveWithSession:[PFFacebookUtils session]];

// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

关于ios - 通过 Safari 或 FB App 登录 Facebook 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26354801/

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