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! :)

Alex
  • 63
  • 1
  • 6
  • Thanks Dharmesh! It's much better now! How did you do it? I mean,by using some image hosting site or something else? – Alex Nov 03 '15 at 13:16
  • you need reputation to attach images. – tuledev Nov 03 '15 at 14:05
  • Oh ok :) Thank you,anhtu! – Alex Nov 05 '15 at 03:32
  • 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 app – curveorzos Nov 13 '15 at 23:58

1 Answers1

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.

Mihai
  • 711
  • 1
  • 9
  • 14
  • You lifesaver. The subtly different signature for this AppDelegate method cost us many hours.. – MattD Feb 17 '17 at 03:11