AppDelegate.swift 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import UIKit
  17. import FirebaseCore
  18. import GoogleSignIn
  19. @UIApplicationMain
  20. class AppDelegate: UIResponder, UIApplicationDelegate {
  21. /** @var kGoogleClientID
  22. @brief The Google client ID.
  23. */
  24. private let kGoogleClientID = AuthCredentials.GOOGLE_CLIENT_ID
  25. // TODO: add Facebook login support as well.
  26. /** @var kFacebookAppID
  27. @brief The Facebook app ID.
  28. */
  29. private let kFacebookAppID = AuthCredentials.FACEBOOK_APP_ID
  30. /** @var window
  31. @brief The main window of the app.
  32. */
  33. var window: UIWindow?
  34. func application(_ application: UIApplication,
  35. didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  36. FirebaseApp.configure()
  37. GIDSignIn.sharedInstance().clientID = kGoogleClientID
  38. return true
  39. }
  40. @available(iOS 9.0, *)
  41. func application(_ application: UIApplication, open url: URL,
  42. options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
  43. return GIDSignIn.sharedInstance().handle(url,
  44. sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String,
  45. annotation: nil)
  46. }
  47. func application(_ application: UIApplication, open url: URL, sourceApplication: String?,
  48. annotation: Any) -> Bool {
  49. return GIDSignIn.sharedInstance().handle(url, sourceApplication: sourceApplication,
  50. annotation: annotation)
  51. }
  52. }