FirebaseSessions.swift 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2022 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. import Foundation
  15. import FirebaseCore
  16. // Avoids exposing internal FirebaseCore APIs to Swift users.
  17. @_implementationOnly import FirebaseCoreExtension
  18. @objc(FIRSessionsProvider)
  19. protocol SessionsProvider {
  20. @objc static func sessions() -> Void
  21. }
  22. @objc(FIRSessions) class Sessions: NSObject, Library, SessionsProvider {
  23. // MARK: - Private Variables
  24. /// The app associated with all sessions.
  25. private let googleAppID: String
  26. // MARK: - Initializers
  27. required init(app: FirebaseApp) {
  28. googleAppID = app.options.googleAppID
  29. }
  30. // MARK: - Library conformance
  31. static func componentsToRegister() -> [Component] {
  32. return [Component(SessionsProvider.self,
  33. instantiationTiming: .alwaysEager,
  34. dependencies: []) { container, isCacheable in
  35. // Sessions SDK only works for the default app
  36. guard let app = container.app, app.isDefaultApp else { return nil }
  37. isCacheable.pointee = true
  38. return self.init(app: app)
  39. }]
  40. }
  41. // MARK: - SessionsProvider conformance
  42. static func sessions() {}
  43. }