Facebook 登录页面在 IOS 9 中显示空白页面

Facebook login page showing blank page in IOS 9

我正在使用 FBSDKCoreKit (4.12.0) FBSDKLoginKit (4.12.0) 首先我得到屏幕 1

此方法永远不会被调用。

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

收到此警告

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

然后我按确定按钮我得到空白页面而没有移动到任何其他页面

我用的plist文件是

为了转运安全

    <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>

我用代码登录 Fabook,在 iOS 8 和 9 上都可以正常工作。希望这对你有帮助。

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

我是如何找到上述问题的解决方案的

1) 早些时候我创建了一个按钮并给定了 FBLoginButton class 并且在操作中我写了

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

解决方案修改:删除 FBLoginButton class 并仅放置 UIButton

2) 同时使用 ios 8 和 ios 9 方法,如下面在 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
            ];
}