FIRAppInternal.h 6.0 KB

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