6

I update my Xcode to 7 , and Facebook to 4.6 sdk.

this My warning :

Warning: Attempt to present <FBSDKContainerViewController: 0x159337700> on <UIAlertController: 0x159262700> whose view is not in the window hierarchy!

in My project the BitCode is NO - because if I turn it to Yes I got this Error :

ld:'/Users/MyName/Desktop/MyProjectName/ProjectName/ProjectName/Resources/Frameworks/Fabric.framework/Fabric(Fabric.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

this is the parse method :

-(void)signInWithFacebookClicked
{
NSArray *permissions = [NSArray arrayWithObjects:@"email",@"user_friends", nil];
[PFFacebookUtils logInInBackgroundWithReadPermissions:permissions block:^(PFUser *user, NSError *error)
 {
     if (!user) // The user cancelled the Facebook login
     {
         NSLog(@"Uh oh. The user cancelled the Facebook login.");
     }
     else if (user.isNew) // New user (not stored on DB) - User signed up and logged in through Facebook
     {
         [self handleNewUser];
     }
     else if (user) // the user is exist at DB
     {
       // the user is exist at DB  
     }
     else if (error)
     {
        // showAlertOfSomethingWentWrong
     }
 }];
}

this is FBSDKGraphRequest :

-(void)handleNewUser
{

FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"friends, first_name, gender, last_name, link, name, verified, picture, email"}];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error)
 {
     NSMutableDictionary *userData = (NSMutableDictionary *)result;
}];

my problem is that that line :

[PFFacebookUtils logInInBackgroundWithReadPermissions:permissions block:^(PFUser *user, NSError *error)

the run never go into this block in iPhone , in simulator this work fine.

Roei Nadam
  • 1,780
  • 1
  • 15
  • 33

4 Answers4

2

I had a similar problem where I was trying to show a login alert on top of FBSDKContainerViewController.

In this call

- (void)logInWithReadPermissions:(NSArray *)permissions
          fromViewController:(UIViewController *)fromViewController
                     handler:(FBSDKLoginManagerRequestTokenHandler)handler;

Facebook presents its own view controller and if you don't specify the fromViewController, "the topmost view controller will be automatically determined as best as possible."

In your case, it sounds like Facebook is trying to present on top of an alert that was dismissed, even if this is not the call being invoked.

PastryPup
  • 166
  • 1
  • 8
  • Hi! I'm having that exact same problem too! but in LogInWithWritePermissions... How did you fix it? – rickrvo Jul 19 '16 at 00:49
  • 1
    @rickrvo - I don't have access to my code anymore, but I think I either specified a fromViewController so Facebook wouldn't infer an incorrect view or I made sure the alert I was presenting was not showing anymore. – PastryPup Jul 20 '16 at 17:15
  • 1
    I found a workaround! The thing is that loginwithWritePermissions was being called right after another loginWithReadPermissions... And the iOS didn't have time to go back to the app before calling loginWithWritePermissions so it got a different viewController. A quick fix was to add 1 second delay before the WritePermissions call so the iOS could change back to the app and then the second call worked fine – rickrvo Jul 21 '16 at 19:04
0

do you add NSAppTransportSecurity & LSApplicationQueriesSchemes key to your info.plist?

iSibDev
  • 340
  • 5
  • 18
0

I did find a workaround to this, thanks to @PastryPup's answer.

The warning is displayed when trying to present the Facebook login view controller on top of a dismissed alertview. Switching to a UIAlertController, however, fixed the problem.

My impression is that this works because UIAlertController is a full-fledged controller, and thus exists in the view hierarchy even after it has been dismissed.

The solution is to basically replace the UIAlertView with a UIAlertController, and call [PFFacebookUtils logInInBackgroundWithReadPermissions:permissions block:^(PFUser *user, NSError *error) inside the default action of the UIAlerController.

Link on how to implement a UIAlertController

verybadalloc
  • 5,768
  • 2
  • 33
  • 49
0

I did some trick to make this work. I don't know if it's the best way to do it. But i just made a boolean that is false before the activity executes (the fb button is tapped). So after it returns, just set the boolean to true and have a condition in the ViewDidAppear that if the boolean is true perform the segue to the next window you want to go. I hope it helps!