IOS-Facebook Blank white screen after app is authorized
Asked Answered
B

1

6

I am upgrading from Parse v1.6.4 to the latest version and also i am upgrading facebook ios sdk to v4.7. The problem is after the app is authorized,it shows a blank white screen and if i click "done",it closes the safari and in the log it shows that,user cancelled login.
It was working fine before upgrading it to the new version.

my plist

<key>CFBundleURLTypes</key>
 <array>
  <dict>
   <key>CFBundleURLSchemes</key>
 <array>
 <string>fbxxxxxx</string>
 </array>
 </dict>
</array>
<key>FacebookAppID</key>
<string><my FacebookAppID></string>
<key>FacebookDisplayName</key>
<string>my appname</string>

white listing FB server

<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>facebook.com</key>
<dict>
  <key>NSIncludesSubdomains</key>
  <true/>
  <key>NSExceptionRequiresForwardSecrecy</key>
  <false/>
</dict>
<key>fbcdn.net</key>
<dict>
  <key>NSIncludesSubdomains</key>
  <true/>
  <key>NSExceptionRequiresForwardSecrecy</key>
  <false/>
</dict>
<key>akamaihd.net</key>
<dict>
  <key>NSIncludesSubdomains</key>
  <true/>
  <key>NSExceptionRequiresForwardSecrecy</key>
  <false/>
</dict>

<key>LSApplicationQueriesSchemes</key>
 <array>
  <string>fbapi</string>
  <string>fb-messenger-api</string>
  <string>fbauth2</string>
  <string>fbshareextension</string>
</array>

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

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  return [[FBSDKApplicationDelegate sharedInstance] application:application
                                    didFinishLaunchingWithOptions:launchOptions];
}

viewController.m

-(IBAction)facebookLogin:(id)sender
{
    FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];

    if ([FBSDKAccessToken currentAccessToken])
    {
        //Do something

    }
    else
    {
        [login logInWithReadPermissions:@[@"email"] fromViewController:nil handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
         {
             if (error)
             {
                 NSLog(@"Error");
             }
             else if (result.isCancelled)
             {
                 NSLog(@"User cancelled login");
             }
             else
             {
                 NSLog(@"Login Success");

                 if ([result.grantedPermissions containsObject:@"email"])
                 {
                     NSLog(@"result is:%@",result);

                 }
                 else
                 {
                     NSLog(@"FB email permission error");

                 }
             }
         }];
    }
}

Here's an image of the screen.

enter image description here

I am running this test app in my IPhone 6 device.
Thank you! :)

Edit 1:
Today,i upgraded my project to Facebook's new v4.8 SDk and this time,it seems like it's working.
I am not sure,what i was doing wrong at that time but it's working now for arm64 devices.
But when i enable support for armv7s,it's giving me this error...

ld: file is universal (4 slices) but does not contain a(n) armv7s slice:

It points to FBSDKLoginKit.framework.
Are armv7s devices not supported anymore?
Is there anyway to get rid of this error?
Thank you! :)

Begga answered 3/11, 2015 at 13:5 Comment(4)
Thanks Dharmesh! It's much better now! How did you do it? I mean,by using some image hosting site or something else?Begga
you need reputation to attach images.Nowhere
Oh ok :) Thank you,anhtu!Begga
As a first glance it looks like everything's fine, so it might be a configuration issue? I would check that the Facebook App ID you set on your app is the one you intend to use, and that your Facebook Application Settings are set correctly for iOS. Also I would check you are trying to log in as someone who is admin, dev or tester of the appRepentance
E
3

I had the same problem and it turned out that

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool 

is deprecated in ios 9.0. I also had implemented the method

func application(application: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool 

so FB SDK was calling the latter. So I had to make sure that I call FBSDKApplicationDelegate in both methods (once for ios 8 and once for ios9).

Here is my implementation of AppDelegate:

 @available(iOS 9.0, *)
func application(application: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
    let handled = FBSDKApplicationDelegate.sharedInstance().application(application,
                                                                        openURL: url,
                                                                        sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as! String,
                                                                        annotation: options [UIApplicationOpenURLOptionsAnnotationKey])
    if !handled {
        return self.openURL(url)
    }
    return true
}

@available(iOS, introduced=8.0, deprecated=9.0)
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
    let handled = FBSDKApplicationDelegate.sharedInstance()
        .application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
    if !handled {
        return self.openURL(url)
    }
    return true
}

where self.openURL(url) can be used to handle other url types beside the facebook ones.

Elbertelberta answered 7/7, 2016 at 6:57 Comment(1)
You lifesaver. The subtly different signature for this AppDelegate method cost us many hours..Kosaka

© 2022 - 2024 — McMap. All rights reserved.