gpt4 book ai didi

ios - 用于解析 iOS 应用程序的 Facebook 登录无法正常工作

转载 作者:行者123 更新时间:2023-11-29 12:22:19 25 4
gpt4 key购买 nike

我已经按照教程 here 中的描述添加了 facebook 登录按钮.然而,当我尝试对此进行测试时,FB 登录按钮只显示一个加载指示器,应用程序卡住。还有其他我忘记实现的集成吗?

AppDelegate.m:

- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {

return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
[FBSDKAppEvents activateApp];
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
// 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.

// Start updating locations when the app returns to the foreground.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
DefaultSettingsViewController *defaultSettingsViewController = [storyboard instantiateViewControllerWithIdentifier:@"DefaultSettingsViewController"];
//[defaultSettingsViewController.locationManager stopUpdatingLocation];

// Clear badge when app is opened
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
if (currentInstallation.badge != 0) {
currentInstallation.badge = 0;
[currentInstallation saveEventually];
}

[FBSDKAppEvents activateApp];

[FBAppCall handleDidBecomeActiveWithSession:[PFFacebookUtils session]];

}

DefaultViewController.m:

- (void)_loginWithFacebook {
// Set permissions required from the facebook user account
NSArray *permissionsArray = @[ @"user_about_me", @"user_relationships", @"user_birthday", @"user_location"];

// Login PFUser using Facebook
[PFFacebookUtils logInInBackgroundWithReadPermissions:permissions block:^(PFUser *user, NSError *error) {
if (!user) {
NSLog(@"Uh oh. The user cancelled the Facebook login.");
} else if (user.isNew) {
NSLog(@"User signed up and logged in through Facebook!");
} else {
NSLog(@"User logged in through Facebook!");
}
}];
}

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];

if (![PFUser currentUser]) { // No user logged in
// Create the log in view controller
PFLogInViewController *logInViewController = [[PFLogInViewController alloc] init];
[logInViewController setDelegate:self]; // Set ourselves as the delegate
[logInViewController setFacebookPermissions:[NSArray arrayWithObjects:@"friends_about_me", nil]];
[logInViewController setFields: PFLogInFieldsUsernameAndPassword | PFLogInFieldsLogInButton | PFLogInFieldsFacebook | PFLogInFieldsSignUpButton | PFLogInFieldsPasswordForgotten];

// Create the sign up view controller
PFSignUpViewController *signUpViewController = [[PFSignUpViewController alloc] init];
[signUpViewController setDelegate:self]; // Set ourselves as the delegate

// Assign our sign up controller to be displayed from the login controller
[logInViewController setSignUpController:signUpViewController];

// Present the log in view controller
[self presentViewController:logInViewController animated:YES completion:NULL];
} else {
[self performSegueWithIdentifier:@"login" sender:self];
}

}

最佳答案

您能否在 DefaultViewController.m 中的代码行上使用断点重新运行您的应用

[logInViewController setDelegate:self]; // Set ourselves as the delegate

然后在身份检查器中告诉我它包含哪些对象?

我对 Parse 没有太多经验,但听起来其中一个框架可能没有正确实现。 (如果是这种情况,这是一个快速修复。您只需重新下载并将其放回您的应用程序中即可)

关于ios - 用于解析 iOS 应用程序的 Facebook 登录无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30224599/

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