FIRApp.h 4.7 KB

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