Facebook login - stays at white web page SWIFT

前端 未结 3 696
情书的邮戳
情书的邮戳 2021-01-13 07:49

In my LoginViewController, I implemented the FBSDKLoginButtonDelegate and imported the FBSDKLoginKit & FBSDKCoreKit. My code in viewDidLoad is as appears:



        
相关标签:
3条回答
  • 2021-01-13 08:04

    The AppDelegate was missing:

    func application(application: UIApplication,
                 openURL url: NSURL,
                 sourceApplication: String?,
                 annotation: AnyObject?) -> Bool {
      return FBSDKApplicationDelegate.sharedInstance().application(application,
                                                      openURL: url,
                                                      sourceApplication: sourceApplication,
                                                             annotation: annotation)
     }
    
    0 讨论(0)
  • 2021-01-13 08:14

    As stated above missing app delegate but in two places.

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
    }
    

    and

    func application(application: UIApplication,
        openURL url: NSURL,
        sourceApplication: String?,
        annotation: AnyObject) -> Bool {
            return FBSDKApplicationDelegate.sharedInstance().application(
                application,
                openURL: url,
                sourceApplication: sourceApplication,
                annotation: annotation)
    }
    
    0 讨论(0)
  • 2021-01-13 08:30

    Here's my situation: I could use myapp to login with fb. Then when I close the app (back to home screen) and enter the app again, it presents me a blank screen. And I solved it by these:

    In the app delegate:

    func applicationDidBecomeActive(application: UIApplication) {
        FBSDKAppEvents.activateApp()
    }
    

    Also, I'm using the bridging file from this article: http://www.brianjcoleman.com/tutorial-how-to-use-login-in-facebook-sdk-4-0-for-swift/

    The bridging file looks like this:

    #ifndef Bridging_Header_h
    #define Bridging_Header_h
    
    #import <FBSDKCoreKit/FBSDKCoreKit.h>
    #import <FBSDKLoginKit/FBSDKLoginKit.h>
    
    #endif /* Bridging_Header_h */
    
    0 讨论(0)
提交回复
热议问题