[英]Cannot assign value of type 'AppDelegate' to type 'GIDSignInDelegate!"
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. self.initialize() IQKeyboardManager.sharedManager().enable = true TimeSyncManager.sharedInstance.syncTimeWithServer(withNotifcationOption: false) AppScreenManager.sharedInstance.setUpInitialScreen() SDKApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions) //setUpGoogleSDK() var configureError: NSError? GGLContext.sharedInstance().configureWithError(&configureError) assert(configureError == nil, "Error configuring Google services: \\(configureError)") GIDSignIn.sharedInstance().delegate = self //<<--------Error at this Point application.registerForRemoteNotifications() UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in //Parse errors and track state } return true
Now the problem I face is that Appdelegate shows error that- Type 'AppDelegate' does not conform to protocol 'GIDSignInDelegate' 现在我面临的问题是Appdelegate显示错误-类型'AppDelegate'不符合协议'GIDSignInDelegate'
My AppDelegate Code is 我的AppDelegate代码是
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate { var window: UIWindow? public func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!){ } // Finished disconnecting |user| from the app successfully if |error| is |nil|. public func sign(_ signIn: GIDSignIn!, didDisconnectWith user: GIDGoogleUser!, withError error: Error!){ } }
You have implemented GIDSignInUIDelegate
instead of GIDSignInDelegate
. 您已经实现了GIDSignInUIDelegate
而不是GIDSignInDelegate
。 Simply implement the GIDSignInDelegate
will remove the compile error. 只需实现GIDSignInDelegate
消除编译错误。
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {
Don't forgot to implement methods of GIDSignInDelegate
with AppDelegate
. 不要忘记使用AppDelegate
实现GIDSignInDelegate
方法。
func sign(_ signIn: GIDSignIn!, didDisconnectWith user: GIDGoogleUser!, withError error: Error!) {
}
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
}
You need to implement GIDSignInDelegate in AppDelegate 您需要在AppDelegate中实现GIDSignInDelegate
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {
func googleSignIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!) {
}
func googleSignOut() {
}
// Implement the required GIDSignInDelegate methods and Unauth when disconnected from Google
func signIn(signIn: GIDSignIn!, didDisconnectWithUser user:GIDGoogleUser!, withError error: NSError!) {
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.