Search code examples
objective-cios9facebook-sdk-4.x

Facebook login page showing blank page in IOS 9


I am using FBSDKCoreKit (4.12.0) FBSDKLoginKit (4.12.0) first i am getting screen 1

This method is block is never called .

FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email",@"public_profile"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
    //never called
}];

getting this warning

 Warning: Attempt to present <FBSDKContainerViewController: 0x16570810> on <ViewController: 0x16528870> whose view is not in the window hierarchy!

enter image description here

Then i press ok button i am getting blank page without moving to any other page

enter image description here

Plist file i used is

For Transpost security

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

Query schems


    <key>LSApplicationQueriesSchemes</key>
        <array>
            <string>fbauth</string>
            <string>fbapi</string>
            <string>fb-messenger-api</string>
            <string>fbauth2</string>
            <string>fbshareextension</string>
            <string>fbapi20130214</string>
            <string>fbapi20130410</string>
            <string>fbapi20130702</string>
            <string>fbapi20131010</string>
            <string>fbapi20131219</string>
            <string>fbapi20131219</string>
            <string>fbapi20140410</string>
            <string>fbapi20140116</string>
            <string>fbapi20150313</string>
            <string>fbapi20150629</string>
            <string>fb-messenger-api20140430</string>
        </array>
        <key>CFBundleURLTypes</key>
        <array>
            <dict>
                <key>CFBundleURLSchemes</key>
                <array>
                    <string>fb268237443567174</string>
                </array>
            </dict>
        </array>
        <key>FacebookAppID</key>
        <string>268237443567174</string>
        <key>FacebookDisplayName</key>
        <string>MyAPP</string>

Solution

  • How i found solution for the above problem is

    1)Earlier i have created a button and given FBLoginButton class and in action i wrote like

    FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
    [login logInWithReadPermissions:@[@"email",@"public_profile"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
        //never called
    }];
    

    Modification for solution: Removed the FBLoginButton class and put only UIButton

    2)Use both ios 8 and ios 9 methods like below written in AppDelegate.

    - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options {
        return [[FBSDKApplicationDelegate sharedInstance] application:app
                                                              openURL:url
                                                    sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                                                           annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
    }
    
    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
    {
    
        return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                              openURL:url
                                                    sourceApplication:sourceApplication
                                                           annotation:annotation
                ];
    }