我正在关注https://firebase.google.com/docs/auth/并希望使用 FirebaseUI ( https://github.com/firebase/FirebaseUI-iOS/tree/master/FirebaseUI ) 进行身份验证。
UI 显示成功,我可以单击“使用 google 登录”,然后完成网络登录流程。该应用程序使用 auth url 重新打开,但 authUI 函数永远不会触发。怎么了?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
let authUI = FIRAuthUI.authUI()!;
NSLog("setting up delegate");
authUI.delegate = self;
let googleAuthUI = FIRGoogleAuthUI.init(clientID:FIRApp.defaultApp()!.options.clientID);
authUI.signInProviders = [googleAuthUI!];
mSplitViewController = self.window!.rootViewController as! UISplitViewController
self.window!.rootViewController = authUI.authViewController();
return true
}
func authUI(authUI: FIRAuthUI, didSignInWithUser user: FIRUser?, error:NSError?) {
// Implement this method to handle signed in user or error if any.
NSLog("logged in");
self.window!.rootViewController = mSplitViewController
let navigationController = mSplitViewController!.viewControllers[mSplitViewController!.viewControllers.count-1] as! UINavigationController
navigationController.topViewController!.navigationItem.leftBarButtonItem = mSplitViewController!.displayModeButtonItem()
mSplitViewController!.delegate = self
let masterNavigationController = mSplitViewController!
.viewControllers[0] as! UINavigationController
let controller = masterNavigationController.topViewController as! MasterViewController
controller.managedObjectContext = self.managedObjectContext
}
func application(application: UIApplication,
openURL url: NSURL, options: [String: AnyObject]) -> Bool {
NSLog("opened with url \(url)");
FIRAuthUI.authUI()!.delegate = self;
return FIRAuthUI.authUI()!.handleOpenURL(url, sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] as! String);
}