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
现在我遇到的问题是Appdelegate显示错误 - 类型'AppDelegate'不符合协议'GIDSignInDelegate'
我的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!){
}
}
答案 0 :(得分:3)
您已实施GIDSignInUIDelegate
而非GIDSignInDelegate
。只需实现GIDSignInDelegate
将删除编译错误。
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {
不要忘记使用GIDSignInDelegate
实现AppDelegate
的方法。
func sign(_ signIn: GIDSignIn!, didDisconnectWith user: GIDGoogleUser!, withError error: Error!) {
}
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
}
答案 1 :(得分:1)
您需要在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!) {
}
}