CoreAPITests.swift 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 { _ /* success */ in
  41. // ...
  42. }
  43. if #available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 7.0, *) {
  44. // async/await is a Swift Concurrency feature available on iOS 13+ and macOS 10.15+
  45. Task {
  46. await app.delete()
  47. }
  48. }
  49. }
  50. // Properties
  51. if let app = FirebaseApp.app() {
  52. _ = app.name
  53. _ = app.options
  54. _ = app.isDataCollectionDefaultEnabled
  55. app.isDataCollectionDefaultEnabled = false
  56. }
  57. // MARK: - FirebaseConfiguration
  58. _ = FirebaseConfiguration.shared
  59. FirebaseConfiguration.shared.setLoggerLevel(.debug)
  60. // MARK: - FirebaseLoggerLevel
  61. let loggerLevel: FirebaseLoggerLevel = .debug
  62. switch loggerLevel {
  63. case FirebaseLoggerLevel.error:
  64. break
  65. case FirebaseLoggerLevel.warning:
  66. break
  67. case FirebaseLoggerLevel.notice:
  68. break
  69. case FirebaseLoggerLevel.info:
  70. break
  71. case FirebaseLoggerLevel.debug:
  72. break
  73. default:
  74. break
  75. }
  76. _ = FirebaseLoggerLevel.min
  77. _ = FirebaseLoggerLevel.max
  78. // MARK: - FirebaseOptions
  79. // FirebaseOptions default instance
  80. if let _ /* defaultOptions */ = FirebaseOptions.defaultOptions() {
  81. // ...
  82. }
  83. // FirebaseOptions initializers
  84. _ = FirebaseOptions(googleAppID: "googleAppID", gcmSenderID: "gcmSenderID")
  85. if let _ /* options */ = FirebaseOptions(contentsOfFile: "path/to/file") {
  86. // ...
  87. }
  88. // Properties
  89. if let options = FirebaseOptions.defaultOptions() {
  90. _ = options.bundleID
  91. _ = options.gcmSenderID
  92. _ = options.googleAppID
  93. if let _ /* apiKey */ = options.apiKey {
  94. // ...
  95. }
  96. if let _ /* clientID */ = options.clientID {
  97. // ...
  98. }
  99. if let _ /* projectID */ = options.projectID {
  100. // ...
  101. }
  102. if let _ /* databaseURL */ = options.databaseURL {
  103. // ...
  104. }
  105. if let _ /* deepLinkURLScheme */ = options.deepLinkURLScheme {
  106. // ...
  107. }
  108. if let _ /* storageBucket */ = options.storageBucket {
  109. // ...
  110. }
  111. if let _ /* appGroupID */ = options.appGroupID {
  112. // ...
  113. }
  114. }
  115. // MARK: - FirebaseVersion
  116. _ = FirebaseVersion()
  117. }
  118. }