私は私の最初のビューで私のログインボタンをクリックすると私はGoogleのsignIn APIを使用して私はアクセスしてsegueのためのperformeを使用した後、自分自身を記録し、私のデータを取得することができます2番目のビュー。 2番目のビューでログアウトしようとすると、私の文字列「deco」が表示され、最初のページに戻ります。しかし、私は再び自分自身を記録しようとすると、彼はこのエラーでクラッシュ:AppDelegate送信応答swift3
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'uiDelegate must either be a |UIViewController| or implement the |signIn:presentViewController:| and |signIn:dismissViewController:| methods from |GIDSignInUIDelegate|.'
私はログアウト機能が動作しませんでしたと思うし、また、私はappDelegateでセグエの利用performeが最高Methodeのだとは思いませんあなたは何か他のものでそれを作っていますか?私は同じことを持っている私の2番目のビューで
マイfirstViewController
class ViewController: UIViewController, GIDSignInUIDelegate{
override func viewDidLoad() {
super.viewDidLoad()
GIDSignIn.sharedInstance().uiDelegate = self
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func btn(_ sender: Any) {
GIDSignIn.sharedInstance().signIn()
}}
(届出を期待)、唯一の変更は)GIDSignIn.sharedInstance(である。切断()
マイappDelegate
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
var configureError : NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
if (configureError != nil)
{
print("We have an error ! \(configureError)")
}
else
{
print("Google ready sir !")
}
GIDSignIn.sharedInstance().delegate = self
return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
return GIDSignIn.sharedInstance().handle(
url,
sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String,
annotation: options[UIApplicationOpenURLOptionsKey.annotation])
}
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!)
{
if (error == nil) {
// Perform any operations on signed in user here.
let userId = user.userID // For client-side use only!
let idToken = user.authentication.accessToken // Safe to send to the server
let fullName = user.profile.name
let givenName = user.profile.givenName
let familyName = user.profile.familyName
let email = user.profile.email
print("userId =>\(userId)")
print("idToken =>\(idToken)")
print("fullName =>\(fullName)")
print(" familyName=>\(familyName)")
print(" givenName=>\(givenName)")
print("email =>\(email)")
print("info => \(user.authentication)")
guard let rvc = self.window?.rootViewController as? ViewController
else {
return
}
rvc.performSegue(withIdentifier: "test", sender: nil)
} else {
print("\(error.localizedDescription)")
}
}
func sign(_ signIn: GIDSignIn!, didDisconnectWith user: GIDGoogleUser!, withError error: Error!)
{
print("Deco")
}
// Other func not usefull
が含まれています
}
を、私は、同じメッセージでクラッシュを得ました一度でもログすることはできません –