FIRAppInternal.h 6.1 KB

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