FIRApp.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 <Foundation/Foundation.h>
  17. @class FIROptions;
  18. NS_ASSUME_NONNULL_BEGIN
  19. /** A block that takes a BOOL and has no return value. */
  20. typedef void (^FIRAppVoidBoolCallback)(BOOL success)
  21. NS_SWIFT_UNAVAILABLE("Use Swift's closure syntax instead.");
  22. /**
  23. * The entry point of Firebase SDKs.
  24. *
  25. * Initialize and configure `FirebaseApp` using `FirebaseApp.configure()`
  26. * or other customized ways as shown below.
  27. *
  28. * The logging system has two modes: default mode and debug mode. In default mode, only logs with
  29. * log level Notice, Warning and Error will be sent to device. In debug mode, all logs will be sent
  30. * to device. The log levels that Firebase uses are consistent with the ASL log levels.
  31. *
  32. * Enable debug mode by passing the `-FIRDebugEnabled` argument to the application. You can add this
  33. * argument in the application's Xcode scheme. When debug mode is enabled via `-FIRDebugEnabled`,
  34. * further executions of the application will also be in debug mode. In order to return to default
  35. * mode, you must explicitly disable the debug mode with the application argument
  36. * `-FIRDebugDisabled`.
  37. *
  38. * It is also possible to change the default logging level in code by calling
  39. * `FirebaseConfiguration.shared.setLoggerLevel(_:)` with the desired level.
  40. */
  41. NS_SWIFT_NAME(FirebaseApp)
  42. @interface FIRApp : NSObject
  43. /**
  44. * Configures a default Firebase app. Raises an exception if any configuration step fails. The
  45. * default app is named "__FIRAPP_DEFAULT". This method should be called after the app is launched
  46. * and before using Firebase services. This method should be called from the main thread and
  47. * contains synchronous file I/O (reading GoogleService-Info.plist from disk).
  48. */
  49. + (void)configure;
  50. /**
  51. * Configures the default Firebase app with the provided options. The default app is named
  52. * "__FIRAPP_DEFAULT". Raises an exception if any configuration step fails. This method should be
  53. * called from the main thread.
  54. *
  55. * @param options The Firebase application options used to configure the service.
  56. */
  57. + (void)configureWithOptions:(FIROptions *)options NS_SWIFT_NAME(configure(options:));
  58. /**
  59. * Configures a Firebase app with the given name and options. Raises an exception if any
  60. * configuration step fails. This method should be called from the main thread.
  61. *
  62. * @param name The application's name given by the developer. The name should should only contain
  63. Letters, Numbers and Underscore.
  64. * @param options The Firebase application options used to configure the services.
  65. */
  66. // clang-format off
  67. + (void)configureWithName:(NSString *)name
  68. options:(FIROptions *)options NS_SWIFT_NAME(configure(name:options:));
  69. // clang-format on
  70. /**
  71. * Returns the default app, or `nil` if the default app does not exist.
  72. */
  73. + (nullable FIRApp *)defaultApp NS_SWIFT_NAME(app());
  74. /**
  75. * Returns a previously created `FirebaseApp` instance with the given name, or `nil` if no such app
  76. * exists. This method is thread safe.
  77. */
  78. + (nullable FIRApp *)appNamed:(NSString *)name NS_SWIFT_NAME(app(name:));
  79. /**
  80. * Returns the set of all extant `FirebaseApp` instances, or `nil` if there are no `FirebaseApp`
  81. * instances. This method is thread safe.
  82. */
  83. @property(class, readonly, nullable) NSDictionary<NSString *, FIRApp *> *allApps;
  84. /**
  85. * Cleans up the current `FirebaseApp`, freeing associated data and returning its name to the pool
  86. * for future use. This method is thread safe.
  87. */
  88. - (void)deleteApp:(void (^)(BOOL success))completion;
  89. /**
  90. * `FirebaseApp` instances should not be initialized directly. Call `FirebaseApp.configure()`,
  91. * `FirebaseApp.configure(options:)`, or `FirebaseApp.configure(name:options:)` directly.
  92. */
  93. - (instancetype)init NS_UNAVAILABLE;
  94. /**
  95. * Gets the name of this app.
  96. */
  97. @property(nonatomic, copy, readonly) NSString *name;
  98. /**
  99. * Gets a copy of the options for this app. These are non-modifiable.
  100. */
  101. @property(nonatomic, copy, readonly) FIROptions *options;
  102. /**
  103. * Gets or sets whether automatic data collection is enabled for all products. Defaults to `true`
  104. * unless `FirebaseDataCollectionDefaultEnabled` is set to `NO` in your app's Info.plist. This value
  105. * is persisted across runs of the app so that it can be set once when users have consented to
  106. * collection.
  107. */
  108. @property(nonatomic, readwrite, getter=isDataCollectionDefaultEnabled)
  109. BOOL dataCollectionDefaultEnabled;
  110. @end
  111. NS_ASSUME_NONNULL_END