Facebook login page showing blank page in IOS 9

我与影子孤独终老i 提交于 2019-12-01 05:34:35

问题


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!

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

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>

回答1:


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



回答2:


I used did code to sign in Fabook, both work fine on iOS 8 and 9. Hope this helps you.

[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"email,name,first_name,last_name"}] startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
        if (!error) {
           //Login success and callback here
        } else {
           //Login failed
        }
    }];


来源:https://stackoverflow.com/questions/37874383/facebook-login-page-showing-blank-page-in-ios-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!