Facebook登录空白页iOS应用程序

时间:2017-12-20 09:09:04

标签: ios facebook facebook-login

我正在尝试将Facebook登录集成到基于Objective C的应用程序中。每个配置都已从Facebook开发人员文档中完成。

问题是我得到空白视图而不是登录视图。这也发生在所有设备和模拟器中。

有人可以帮忙解决这个问题。

FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
    [login
     logInWithReadPermissions: @[@"public_profile",@"email"]
     fromViewController:self
     handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
         if (error) {
             NSLog(@"Process error");
         } else if (result.isCancelled) {
             NSLog(@"Cancelled");
         } else {
             NSLog(@"Logged in");
         }
     }];

Plist配置

 <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fbXXXXXXXXXXXXXX</string>
            </array>
</dict>

<key>FacebookAppID</key>
    <string>XXXXXXXXXXXX</string>
    <key>FacebookDisplayName</key>
    <string>App Name Here</string>

    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbapi</string>
        <string>fbauth2</string>
    </array>

由于 enter image description here

2 个答案:

答案 0 :(得分:0)

我知道这很快但是尝试转换它,它与我完美配合

<key>FacebookAppID</key>
<string>id_Here</string>
<key>FacebookDisplayName</key>
<string>YourAppName</string>

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>fb_id_Here</string>          
        </array>
    </dict>
</array>

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>



    let facebookLogin = FBSDKLoginManager()

    facebookLogin.logOut()        

    facebookLogin.logIn(withReadPermissions: ["public_profile","email", "user_friends"], from:self, handler:
        {


            (facebookResult, facebookError) -> Void in


            let requestMe:FBSDKGraphRequest = FBSDKGraphRequest.init(graphPath: "/me", parameters: ["fields": "id,email, first_name, last_name, gender, picture"])


            let connection : FBSDKGraphRequestConnection = FBSDKGraphRequestConnection()



            connection.add(requestMe, completionHandler: { (con, results, error) in

                //access_token

                if ((error) == nil)

                {

                    print("fname is 20 : \(results!)")



                }
                else

                {


                }

            })


            connection.start()

            if facebookError != nil
            {
                print("Facebook login failed. Error \(String(describing: facebookError))")
            }
            else if (facebookResult?.isCancelled)!
            {

                print("Facebook login was cancelled.")

            }
            else
            {


            }
    })

App代理

 // 9 and later


func application(_ app: UIApplication,
                 open url: URL,
                 options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool

{

    if #available(iOS 9.0, *) {
        let sourceApplication: String? = options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String


            return FBSDKApplicationDelegate.sharedInstance().application(app, open: url, sourceApplication: sourceApplication, annotation: nil)

    }
    else
    {


           print("cvcvcvcvcvcvcc")


      }

  return true

   }

//ios 8

public func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {


    print("qoqpqpqpqpqpqpqpqppq45")

    return FBSDKApplicationDelegate.sharedInstance().application(application, open: url as URL!, sourceApplication: sourceApplication, annotation: annotation)


}

答案 1 :(得分:0)

终于得到了解决方案。只需将登录行为从Native app更改为FBSDKLoginBehaviorWeb即可。