2015-05-13 3 views
1

Я добавил кнопку входа в facebook, как описано в учебнике here. Однако, когда я пытаюсь проверить это, кнопка входа в FB просто показывает индикатор загрузки, и приложение зависает. Есть ли какая-то другая интеграция, которую я забыл реализовать?Facebook login для parse Приложение iOS не работает

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]; 
    } 

} 

ответ

1

Вы можете повторно запустить приложение с точки останова на строке кода в DefaultViewController.m

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

И в инспекторе листинга расскажите, какие объекты он содержит?

У меня не было большого опыта работы с Parse, но похоже, что одна из фреймворков может быть выполнена неправильно. (если это так, это быстро исправить, вы просто повторно загрузите и вернете его в свое приложение)

+0

Я даже не могу добраться до этой точки, потому что этот код запускается после входа пользователя. – TheDudeGuy

+0

Попробуйте задание контрольной точки исключения (вот шаги, если вы не знаете, как это сделать) Зайдите в [Навигатор] и нажмите [Показать навигатор точек останова]. См. Нижнюю часть Навигатора [+] Знак. Нажмите на нее Выберите [Добавить точку останова исключения]. –