(内容に誤りがあった為、訂正しました)
swift4
xcode9.2
Firebase
既にgoogleSignInを実装しています。
参考サイトの
"ステップ6: App Eventsを追加する" まで進みましたが、
画像にあるエラーが出ます。
func application...新たに宣言し、エラー対象のコードを含めてもエラーになります。
この場合、let handled:Bool = FBSDKApplicationDelegate...を
どこに含めれば良いでしょうか?
(AppDelegate) import UIKit import Firebase import FirebaseAuth import GoogleSignIn import SlideMenuControllerSwift import FBSDKCoreKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { print("アプリ起動時の処理だよ") FirebaseApp.configure() GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID GIDSignIn.sharedInstance().delegate = self FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) return true } func applicationWillResignActive(_ application: UIApplication) { print("アプリを閉じそうな感じだよ") } func applicationDidEnterBackground(_ application: UIApplication) { print("アプリを閉じたよ") } func applicationWillEnterForeground(_ application: UIApplication) { print("アプリを開きそうな感じだよ") } func applicationDidBecomeActive(_ application: UIApplication) { print("アプリを開いたよ") FBSDKAppEvents.activateApp() } func applicationWillTerminate(_ application: UIApplication) { print("フリックしてアプリを終了させたよ") } func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { let handled = GIDSignIn.sharedInstance().handle(url, sourceApplication:options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String!, annotation: options[UIApplicationOpenURLOptionsKey.annotation]) return handled let handled:Bool = FBSDKApplicationDelegate.sharedInstance().application(app, open: url, options: options) return handled } func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) { if let error = error { print(error.localizedDescription) return } print("Googleログインが成功したよ") guard let authentication = user.authentication else { return } let credential = GoogleAuthProvider.credential(withIDToken: authentication.idToken, accessToken: authentication.accessToken) Auth.auth().signIn(with: credential, completion: { (user, error) in if let error = error{ print(error.localizedDescription) return } print("Firebaseに正常にログインしたよ") })} func sign(_ signIn: GIDSignIn!, didDisconnectWith user: GIDGoogleUser!, withError error: Error!) { }}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。