FIRAppInternal.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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 <FirebaseCore/FIRApp.h>
  17. @class FIRComponentContainer;
  18. @class FIRHeartbeatLogger;
  19. @protocol FIRLibrary;
  20. /**
  21. * The internal interface to `FirebaseApp`. This is meant for first-party integrators, who need to
  22. * receive `FirebaseApp` notifications, log info about the success or failure of their
  23. * configuration, and access other internal functionality of `FirebaseApp`.
  24. *
  25. * TODO(b/28296561): Restructure this header.
  26. */
  27. NS_ASSUME_NONNULL_BEGIN
  28. typedef NS_ENUM(NSInteger, FIRConfigType) {
  29. FIRConfigTypeCore = 1,
  30. FIRConfigTypeSDK = 2,
  31. };
  32. extern NSString *const kFIRDefaultAppName;
  33. extern NSString *const kFIRAppReadyToConfigureSDKNotification;
  34. extern NSString *const kFIRAppDeleteNotification;
  35. extern NSString *const kFIRAppIsDefaultAppKey;
  36. extern NSString *const kFIRAppNameKey;
  37. extern NSString *const kFIRGoogleAppIDKey;
  38. extern NSString *const kFirebaseCoreErrorDomain;
  39. /** The `UserDefaults` suite name for `FirebaseCore`, for those storage locations that use it. */
  40. extern NSString *const kFirebaseCoreDefaultsSuiteName;
  41. /**
  42. * The format string for the `UserDefaults` key used for storing the data collection enabled flag.
  43. * This includes formatting to append the `FirebaseApp`'s name.
  44. */
  45. extern NSString *const kFIRGlobalAppDataCollectionEnabledDefaultsKeyFormat;
  46. /**
  47. * The plist key used for storing the data collection enabled flag.
  48. */
  49. extern NSString *const kFIRGlobalAppDataCollectionEnabledPlistKey;
  50. /** @var FirebaseAuthStateDidChangeInternalNotification
  51. @brief The name of the @c NotificationCenter notification which is posted when the auth state
  52. changes (e.g. a new token has been produced, a user logs in or out). The object parameter of
  53. the notification is a dictionary possibly containing the key:
  54. @c FirebaseAuthStateDidChangeInternalNotificationTokenKey (the new access token.) If it does not
  55. contain this key it indicates a sign-out event took place.
  56. */
  57. extern NSString *const FIRAuthStateDidChangeInternalNotification;
  58. /** @var FirebaseAuthStateDidChangeInternalNotificationTokenKey
  59. @brief A key present in the dictionary object parameter of the
  60. @c FirebaseAuthStateDidChangeInternalNotification notification. The value associated with this
  61. key will contain the new access token.
  62. */
  63. extern NSString *const FIRAuthStateDidChangeInternalNotificationTokenKey;
  64. /** @var FirebaseAuthStateDidChangeInternalNotificationAppKey
  65. @brief A key present in the dictionary object parameter of the
  66. @c FirebaseAuthStateDidChangeInternalNotification notification. The value associated with this
  67. key will contain the FirebaseApp associated with the auth instance.
  68. */
  69. extern NSString *const FIRAuthStateDidChangeInternalNotificationAppKey;
  70. /** @var FirebaseAuthStateDidChangeInternalNotificationUIDKey
  71. @brief A key present in the dictionary object parameter of the
  72. @c FirebaseAuthStateDidChangeInternalNotification notification. The value associated with this
  73. key will contain the new user's UID (or nil if there is no longer a user signed in).
  74. */
  75. extern NSString *const FIRAuthStateDidChangeInternalNotificationUIDKey;
  76. @interface FIRApp ()
  77. /**
  78. * A flag indicating if this is the default app (has the default app name).
  79. */
  80. @property(nonatomic, readonly) BOOL isDefaultApp;
  81. /**
  82. * The container of interop SDKs for this app.
  83. */
  84. @property(nonatomic) FIRComponentContainer *container;
  85. /**
  86. * The heartbeat logger associated with this app.
  87. *
  88. * Firebase apps have a 1:1 relationship with heartbeat loggers.
  89. */
  90. @property(readonly) FIRHeartbeatLogger *heartbeatLogger;
  91. /**
  92. * Checks if the default app is configured without trying to configure it.
  93. */
  94. + (BOOL)isDefaultAppConfigured;
  95. /**
  96. * Registers a given third-party library with the given version number to be reported for
  97. * analytics.
  98. *
  99. * @param name Name of the library.
  100. * @param version Version of the library.
  101. */
  102. + (void)registerLibrary:(nonnull NSString *)name withVersion:(nonnull NSString *)version;
  103. /**
  104. * Registers a given internal library to be reported for analytics.
  105. *
  106. * @param library Optional parameter for component registration.
  107. * @param name Name of the library.
  108. */
  109. + (void)registerInternalLibrary:(nonnull Class<FIRLibrary>)library
  110. withName:(nonnull NSString *)name;
  111. /**
  112. * Registers a given internal library with the given version number to be reported for
  113. * analytics. This should only be used for non-Firebase libraries that have their own versioning
  114. * scheme.
  115. *
  116. * @param library Optional parameter for component registration.
  117. * @param name Name of the library.
  118. * @param version Version of the library.
  119. */
  120. + (void)registerInternalLibrary:(nonnull Class<FIRLibrary>)library
  121. withName:(nonnull NSString *)name
  122. withVersion:(nonnull NSString *)version;
  123. /**
  124. * A concatenated string representing all the third-party libraries and version numbers.
  125. */
  126. + (NSString *)firebaseUserAgent;
  127. /**
  128. * Can be used by the unit tests in each SDK to reset `FirebaseApp`. This method is thread unsafe.
  129. */
  130. + (void)resetApps;
  131. /**
  132. * Can be used by the unit tests in each SDK to set customized options.
  133. */
  134. - (instancetype)initInstanceWithName:(NSString *)name options:(FIROptions *)options;
  135. @end
  136. NS_ASSUME_NONNULL_END