How to implement Google Sign In with Firebase and Custom Button in Swift? -


i'm having lot of trouble presenting sign in screen google sign in. keep getting variation on application tried present modally active controller

here appdel code:

@available(ios 9.0, *) func application(application: uiapplication,openurl url: nsurl, options: [string: anyobject]) -> bool {     if twitter.sharedinstance().application(application, openurl:url, options: options) {         return true     }     if (fbsdkapplicationdelegate.sharedinstance() != nil)     {         return fbsdkapplicationdelegate.sharedinstance().application(application,             openurl: url,             sourceapplication: options[uiapplicationopenurloptionssourceapplicationkey] as! string,             annotation: options [uiapplicationopenurloptionsannotationkey])     }     if (gidsignin.sharedinstance() != nil){             return gidsignin.sharedinstance().handleurl(url,                 sourceapplication: options[uiapplicationopenurloptionssourceapplicationkey] as? string,                 annotation: options[uiapplicationopenurloptionsannotationkey])     }     return true }  @available(ios, introduced=8.0, deprecated=9.0) func application(application: uiapplication,openurl url: nsurl, sourceapplication: string?, annotation: anyobject) -> bool {     return fbsdkapplicationdelegate.sharedinstance().application(application,         openurl: url,         sourceapplication: sourceapplication!,         annotation: annotation) || gidsignin.sharedinstance().handleurl(url,             sourceapplication: sourceapplication,             annotation: annotation) }   func signin(signin: gidsignin!, didsigninforuser user: gidgoogleuser!,     witherror error: nserror!) {         if let error = error {             print(error.localizeddescription)             return         }         // ... }  func signin(signin: gidsignin!, diddisconnectwithuser user:gidgoogleuser!,     witherror error: nserror!) {         // perform operations when user disconnects app here.         // ... } 

here loginviewcontroller code....

  @ibaction func googlesignin(sender: anyobject)     {         gidsignin.sharedinstance().signin()     }      // present view prompts user sign in google     func signin(signin: gidsignin!,         presentviewcontroller viewcontroller: uiviewcontroller!) {             self.presentviewcontroller(self, animated: true, completion: nil)     }      // dismiss "sign in google" view     func signin(signin: gidsignin!,         dismissviewcontroller viewcontroller: uiviewcontroller!) {             self.dismissviewcontrolleranimated(true, completion: nil)             print("sign in dismissed")     }      func signin(signin: gidsignin!, didsigninforuser user: gidgoogleuser!, witherror error: nserror!) {         gidsignin.sharedinstance().uidelegate = self         let vc = uiapplication.sharedapplication().keywindow?.rootviewcontroller         gidsignin.sharedinstance().uidelegate?.signin!(signin, presentviewcontroller: vc )         if let error = error {             print(error.localizeddescription)             return         }          let authentication = user.authentication          let credential = firgoogleauthprovider.credentialwithidtoken((authentication?.idtoken)!, accesstoken: (authentication?.accesstoken)!)         gidsignin.sharedinstance().uidelegate?.signin!(signin, dismissviewcontroller: self)          firauth.auth()?.signinwithcredential(credential, completion: { (user, error ) -> void in             print(user?.displayname)         })      } 


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -