CoreAPITests.swift 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. //
  2. // Copyright 2021 Google LLC
  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. // MARK: This file is used to evaluate the experience of using Firebase APIs in Swift.
  17. import Foundation
  18. import FirebaseCore
  19. final class CoreAPITests {
  20. func usage() {
  21. // MARK: - FirebaseApp
  22. // Configure Firebase app
  23. FirebaseApp.configure()
  24. if let options = FirebaseOptions(contentsOfFile: "path/to/GoogleService-Info.plist") {
  25. FirebaseApp.configure(name: "App", options: options)
  26. FirebaseApp.configure(options: options)
  27. }
  28. // Retrieve Firebase app(s)
  29. if let _ /* app */ = FirebaseApp.app() {
  30. // ...
  31. }
  32. if let _ /* app */ = FirebaseApp.app(name: "App") {
  33. // ...
  34. }
  35. if let _ /* apps */ = FirebaseApp.allApps {
  36. // ...
  37. }
  38. // Delete Firebase app
  39. if let app = FirebaseApp.app() {
  40. app.delete { _ /* succes */ in
  41. // ...
  42. }
  43. }
  44. #if swift(>=5.5)
  45. if #available(iOS 15.0, macOS 12.0, macCatalyst 15.0, tvOS 15.0, watchOS 8.0, *) {
  46. // async/await is a Swift 5.5+ feature available on iOS 15+
  47. async {
  48. do {
  49. try await app.delete()
  50. } catch {
  51. // ...
  52. }
  53. }
  54. }
  55. #endif // swift(>=5.5)
  56. // Properties
  57. if let app = FirebaseApp.app() {
  58. _ = app.name
  59. _ = app.options
  60. _ = app.isDataCollectionDefaultEnabled
  61. app.isDataCollectionDefaultEnabled = false
  62. }
  63. // MARK: - FirebaseConfiguration
  64. _ = FirebaseConfiguration.shared
  65. FirebaseConfiguration.shared.setLoggerLevel(.debug)
  66. // MARK: - FirebaseLoggerLevel
  67. let loggerLevel: FirebaseLoggerLevel = .debug
  68. switch loggerLevel {
  69. case FirebaseLoggerLevel.error:
  70. break
  71. case FirebaseLoggerLevel.warning:
  72. break
  73. case FirebaseLoggerLevel.notice:
  74. break
  75. case FirebaseLoggerLevel.info:
  76. break
  77. case FirebaseLoggerLevel.debug:
  78. break
  79. default:
  80. break
  81. }
  82. _ = FirebaseLoggerLevel.min
  83. _ = FirebaseLoggerLevel.max
  84. // MARK: - FirebaseOptions
  85. // FirebaseOptions default instance
  86. if let _ /* defaultOptions */ = FirebaseOptions.defaultOptions() {
  87. // ...
  88. }
  89. // FirebaseOptions initializers
  90. _ = FirebaseOptions(googleAppID: "googleAppID", gcmSenderID: "gcmSenderID")
  91. if let _ /* options */ = FirebaseOptions(contentsOfFile: "path/to/file") {
  92. // ...
  93. }
  94. // Properties
  95. if let options = FirebaseOptions.defaultOptions() {
  96. _ = options.bundleID
  97. _ = options.gcmSenderID
  98. _ = options.googleAppID
  99. if let _ /* apiKey */ = options.apiKey {
  100. // ...
  101. }
  102. if let _ /* clientID */ = options.clientID {
  103. // ...
  104. }
  105. if let _ /* trackingID */ = options.trackingID {
  106. // ...
  107. }
  108. if let _ /* projectID */ = options.projectID {
  109. // ...
  110. }
  111. if let _ /* androidClientID */ = options.androidClientID {
  112. // ...
  113. }
  114. if let _ /* databaseURL */ = options.databaseURL {
  115. // ...
  116. }
  117. if let _ /* deepLinkURLScheme */ = options.deepLinkURLScheme {
  118. // ...
  119. }
  120. if let _ /* storageBucket */ = options.storageBucket {
  121. // ...
  122. }
  123. if let _ /* appGroupID */ = options.appGroupID {
  124. // ...
  125. }
  126. }
  127. // MARK: - FirebaseVersion
  128. _ = FirebaseVersion()
  129. }
  130. }