0

I have a Parse.com login that has our design on it. Along with a Facebook button to sign in and register.

The sign up and sign in works fine on the simulator, but I have just put it on an iPhone 5s and when the button is clicked, it ask's weather you want the app to access your information, then after clicking yes it just goes back to the log in screen. I looked at the NSlog and its saying failed to log in.

But as I see on the simulator it seems to work fine.

.m File:

- (void)viewDidAppear:(BOOL)animated
{ 
    [PFFacebookUtils initializeFacebook]; 
    [PFTwitterUtils initializeWithConsumerKey:@"HIDDEN" 
                               consumerSecret:@"HIDDEN"]; 

    // Check if user is logged in 
    if (![PFUser currentUser]) { 
        // Instantiate our custom log in view controller 
        MyLogInViewController *logInViewController = [[MyLogInViewController alloc] init]; 
        [logInViewController setDelegate:self]; 
        [logInViewController setFacebookPermissions:[NSArray arrayWithObjects:@"friends_about_me", nil]]; 
        [logInViewController setFields:PFLogInFieldsUsernameAndPassword 

         //| PFLogInFieldsTwitter 
         | PFLogInFieldsFacebook 
         | PFLogInFieldsSignUpButton 
         | PFLogInFieldsDismissButton]; 

        // Instantiate our custom sign up view controller 
        MySignUpViewController *signUpViewController = [[MySignUpViewController alloc] init]; 
        [signUpViewController setDelegate:self]; 
        [signUpViewController setFields:PFSignUpFieldsDefault | PFSignUpFieldsAdditional]; 

        // Link the sign up view controller 
        [logInViewController setSignUpController:signUpViewController]; 

        // Present log in view controller 
        [self presentViewController:logInViewController animated:YES completion:NULL]; 

    } 

    [super viewDidAppear:animated]; 
    self.canDisplayBannerAds = YES; 
} 

// Sent to the delegate when a PFUser is logged in. 
- (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user { 
    [self dismissViewControllerAnimated:YES completion:NULL]; 
} 

// Sent to the delegate to determine whether the log in request should be submitted to the server. 
- (BOOL)logInViewController:(PFLogInViewController *)logInController shouldBeginLogInWithUsername:(NSString *)username password:(NSString *)password { 

    // Check if both fields are completed 
    if (username && password && username.length != 0 && password.length != 0) { 
        return YES; // Begin login process 

    } 

    [[[UIAlertView alloc] initWithTitle:@"Missing Information" 
                                message:@"Make sure you fill out all of the information!" 
                               delegate:nil 
                      cancelButtonTitle:@"ok" 
                      otherButtonTitles:nil] show]; 
    return NO; // Interrupt login process 
} 

// Sent to the delegate when the log in attempt fails. 
- (void)logInViewController:(PFLogInViewController *)logInController didFailToLogInWithError:(NSError *)error { 
    NSLog(@"Failed to log in..."); 
} 

// Sent to the delegate when the log in screen is dismissed. 
- (void)logInViewControllerDidCancelLogIn:(PFLogInViewController *)logInController { 
    [self dismissViewControllerAnimated:NO completion:nil]; 
    //[self.navigationController popViewControllerAnimated:YES]; 

    [[[UIAlertView alloc] initWithTitle:@"Log In Required" 
                                message:@"Please Make Sure You Log In, Or Sign Up As A New User!" 
                               delegate:nil 
                      cancelButtonTitle:@"ok" 
                      otherButtonTitles:nil] show]; 
} 

// Sent to the delegate when a PFUser is signed up. 
- (void)signUpViewController:(PFSignUpViewController *)signUpController didSignUpUser:(PFUser *)user { 
    [self dismissViewControllerAnimated:YES completion:nil]; // Dismiss the PFSignUpViewController 

} 

// Sent to the delegate when the sign up attempt fails. 
- (void)signUpViewController:(PFSignUpViewController *)signUpController didFailToSignUpWithError:(NSError *)error { 
    NSLog(@"Failed to sign up..."); 
} 

// Sent to the delegate when the sign up screen is dismissed. 
- (void)signUpViewControllerDidCancelSignUp:(PFSignUpViewController *)signUpController { 
    NSLog(@"User dismissed the signUpViewController"); 
}

I only have one more iPhone but it has iOS 8 on it, so I can't try it on that one.

2014-07-23 14:53:30.528 WeddingsAndMore[985:60b] {
    NSLocalizedFailureReason = "com.facebook.sdk:SystemLoginCancelled";
    "com.facebook.sdk:ErrorInnerErrorKey" = "Error Domain=com.apple.accounts Code=7 \"The Facebook server could not fulfill this access request: Invalid permission: friends_about_me\" UserInfo=0x17026b700 {NSLocalizedDescription=The Facebook server could not fulfill this access request: Invalid permission: friends_about_me}";
    "com.facebook.sdk:ErrorLoginFailedReason" = "com.facebook.sdk:SystemLoginCancelled";
    "com.facebook.sdk:ErrorSessionKey" = "<FBSession: 0x17813cca0, state: FBSessionStateClosedLoginFailed, loginHandler: 0x0, appID: 52610783371, urlSchemeSuffix: , tokenCachingStrategy:<PFFacebookTokenCachingStrategy: 0x1780319e0>, expirationDate: (null), refreshDate: (null), attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(null)>";
}

i have removed the friends_about_me now im getting the following

NSLocalizedFailureReason = "com.facebook.sdk:SystemLoginError";
    "com.facebook.sdk:ErrorInnerErrorKey" = "Error Domain=com.apple.accounts Code=7 \"The Facebook server could not fulfill this access request: Invalid application <redacted>\" UserInfo=0x170273040 {NSLocalizedDescription=The Facebook server could not fulfill this access request: Invalid application <redacted>}";
    "com.facebook.sdk:ErrorLoginFailedReason" = "com.facebook.sdk:SystemLoginError";
    "com.facebook.sdk:ErrorSessionKey" = "<FBSession: 0x178125c80, state: FBSessionStateClosedLoginFailed, loginHandler: 0x0, appID: <redacted>, urlSchemeSuffix: , tokenCachingStrategy:<PFFacebookTokenCachingStrategy: 0x17003de60>, expirationDate: (null), refreshDate: (null), attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(null)>";
}

Seems to be i get rid of one error i get another.

there was spaces in the app name in the plist i got rid of the spaces and now i get the following errors

 NSLocalizedFailureReason = "com.facebook.sdk:SystemLoginCancelled";
    "com.facebook.sdk:ErrorInnerErrorKey" = "Error Domain=com.apple.accounts Code=7 \"The Facebook server could not fulfill this access request: An unknown error occurred\" UserInfo=0x17027c8c0 {NSLocalizedDescription=The Facebook server could not fulfill this access request: An unknown error occurred}";
    "com.facebook.sdk:ErrorLoginFailedReason" = "com.facebook.sdk:SystemLoginCancelled";
    "com.facebook.sdk:ErrorSessionKey" = "<FBSession: 0x1781366c0, state: FBSessionStateClosedLoginFailed, loginHandler: 0x0, appID: 6565656656565, urlSchemeSuffix: , tokenCachingStrategy:<PFFacebookTokenCachingStrategy: 0x17003a700>, expirationDate: (null), refreshDate: (null), attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(null)>";
Kappa
  • 1,015
  • 1
  • 16
  • 31
  • Can you print out on an alert/log what the error says? Use [error userInfo] – KerrM Jul 23 '14 at 13:45
  • how do i do that sorry never heard of that one – Mike J Aspinall Jul 23 '14 at 13:47
  • 1
    In your delegate method, where you have `NSLog(@"Failed to log in..."); ` do: `NSLog(@"%@", [error userInfo]);` It will show a description of what the error is. You can also look at `error.code` and compare that code to `https://parse.com/docs/ios/api/Classes/PFConstants.html` to figure out what the error is. – KerrM Jul 23 '14 at 13:48
  • Check Out Main Post for Output. i think it gives me an insight on whats going on in there thanks – Mike J Aspinall Jul 23 '14 at 13:55

1 Answers1

1

You are asking for a permission called "friends_about_me". According to this Facebook doesn't like that. Remove that permission and you should be OK.

A little bit more background - it works on your simulator because the "bug" only manifests itself when you are logged in to Facebook on your device Settings. So, to solve it, either remove the Facebook login from your Settings app, or remove the "friends_about_me" request for permission. Moreover, read and write permissions should be requested separately (i.e. read permissions on login, write permissions when needed) as pointed out here.

Here is a list of updated permissions for Facebook login.

For the second error you are having -- have you made sure that the person trying to login to the app is added as a Tester/Developer/Administrator in your Facebook app if the app is in sandbox mode?

  1. Go to developers.facebook.com
  2. Your app
  3. Roles
  4. Add Facebook ID/Name of the developer / administrator to the app.

Also make sure your FB app ID is correct in your iOS app.

Community
  • 1
  • 1
KerrM
  • 5,139
  • 3
  • 35
  • 60
  • New Error Please check above – Mike J Aspinall Jul 23 '14 at 14:36
  • See updated answer. Also please remove your Facebook app ID from the question! – KerrM Jul 23 '14 at 14:42
  • yes done all the above the app ID was copied and pasted and is correct i was already down as the admin. and i cant add me as the others so i have added trusted people i know to the others – Mike J Aspinall Jul 23 '14 at 14:52
  • What permissions are you requesting from FB on login? Can you post that code? – KerrM Jul 23 '14 at 14:56
  • Latest error looks like the user either: a) didn't give the app permission to run (com.facebook.sdk:SystemLoginCancelled) or b) user had turned off platform applications on Facebook (FB->Privacy->Apps) – KerrM Jul 23 '14 at 15:15
  • ok i will leave it now until i get home and try some one else's iphone.. as this one belongs to someone i dont want to change any of his log on settings – Mike J Aspinall Jul 23 '14 at 15:20