问题描述
我遵循)进行身份验证。
用户界面显示成功,我可以点击使用Google登录,然后完成网络登录流程。该应用程序重新打开身份验证网址,但authUI功能永远不会触发。什么是错的?
func application(application:UIApplication,didFinishLaunchingWithOptions launchOptions:[NSObject:AnyObject]?) - > Bool {
//在应用程序启动后替代自定义点。
FIRApp.configure()
let authUI = FIRAuthUI.authUI()!;
NSLog(建立委托);
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();
返回true
func authUI(authUI:FIRAuthUI,didSignInWithUser用户:FIRUser ?,错误:NSError?){
//实现这个方法处理登录用户或错误,如果有的话。
NSLog(登录);
self.window!.rootViewController = mSplitViewController
let navigationController = mSplitViewController!.viewControllers [mSplitViewController!.viewControllers.count-1] as! UINavigationController
$ b $ navigationController.topViewController!.navigationItem.leftBarButtonItem = mSplitViewController!.displayModeButtonItem()
mSplitViewController!.delegate = self
let masterNavigationController = mSplitViewController!
.viewControllers [0] as! UINavigationController
让controller = masterNavigationController.topViewController as! MasterViewController
controller.managedObjectContext = self.managedObjectContext
$ b func application(application:UIApplication,
openURL url:NSURL,options:[String: AnyObject]) - > Bool {
NSLog(用url \(url)打开);
FIRAuthUI.authUI()!. delegate = self;
返回FIRAuthUI.authUI()!. handleOpenURL(url,sourceApplication:options [UIApplicationOpenURLOptionsSourceApplicationKey] as!String);
解决方案,但这个StackOverflow的问题已经链接到FirebaseUI仓库的问题部分和有人在那里回应;
Obj-C:
有一个错误,防止 [[FIRAuthUI authUI] authViewController]
被用作应用程序的根视图控制器。解决方法是使用占位符视图控制器作为应用程序的根视图控制器,然后将<$ c
对于Swift用户:
有一个bug防止将 FIRAuthUI.authUI()。authViewController()
用作应用程序的根视图控制器。解决方法是使用占位符视图控制器作为应用程序的根视图控制器,然后在它上面显示 FIRAuthUI.authUI()。authViewController()
。 b
$ b
链接:
I'm following https://firebase.google.com/docs/auth/ and want to use FirebaseUI (https://github.com/firebase/FirebaseUI-iOS/tree/master/FirebaseUI) for authentication.
The UI shows successfully and I'm able to click "sign in with google" and then complete the web sign in flow. The app re-opens with the auth url, but the authUI function never fires. What's wrong?
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);
}
I haven't tried this solution but this StackOverflow problem was linked to the FirebaseUI repo's issues section and someone there responded;
Obj-C:"There's a bug that prevents [[FIRAuthUI authUI] authViewController]
from being used as the root view controller of your app. The workaround is to use a placeholder view controller as your app's root view controller, then present [[FIRAuthUI authUI] authViewController]
on top of it."
for Swift users:There's a bug that prevents FIRAuthUI.authUI().authViewController()
from being used as the root view controller of your app. The workaround is to use a placeholder view controller as your app's root view controller, then present FIRAuthUI.authUI().authViewController()
on top of it.
Link: https://github.com/firebase/FirebaseUI-iOS/issues/65
这篇关于如何在Swift中的iOS上使用FirebaseUI进行Google身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!