FIRAppInternal.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. #if SWIFT_PACKAGE
  17. // TODO(paulb777): Investigate if there's a common strategy for both Cocoapods and Swift PM.
  18. #import "FIRApp.h"
  19. #else
  20. #import <FirebaseCore/FIRApp.h>
  21. #endif
  22. // The has_include is a workaround so the old IID needed for the FIS tests can find FIRErrors.h
  23. #if __has_include("FirebaseCore/Sources/Private/FIRErrors.h")
  24. #import "FirebaseCore/Sources/Private/FIRErrors.h"
  25. #else
  26. #import <FirebaseCore/FIRErrors.h>
  27. #endif
  28. @class FIRComponentContainer;
  29. @protocol FIRLibrary;
  30. /**
  31. * The internal interface to FIRApp. This is meant for first-party integrators, who need to receive
  32. * FIRApp notifications, log info about the success or failure of their configuration, and access
  33. * other internal functionality of FIRApp.
  34. *
  35. * TODO(b/28296561): Restructure this header.
  36. */
  37. NS_ASSUME_NONNULL_BEGIN
  38. typedef NS_ENUM(NSInteger, FIRConfigType) {
  39. FIRConfigTypeCore = 1,
  40. FIRConfigTypeSDK = 2,
  41. };
  42. extern NSString *const kFIRDefaultAppName;
  43. extern NSString *const kFIRAppReadyToConfigureSDKNotification;
  44. extern NSString *const kFIRAppDeleteNotification;
  45. extern NSString *const kFIRAppIsDefaultAppKey;
  46. extern NSString *const kFIRAppNameKey;
  47. extern NSString *const kFIRGoogleAppIDKey;
  48. /**
  49. * The format string for the User Defaults key used for storing the data collection enabled flag.
  50. * This includes formatting to append the Firebase App's name.
  51. */
  52. extern NSString *const kFIRGlobalAppDataCollectionEnabledDefaultsKeyFormat;
  53. /**
  54. * The plist key used for storing the data collection enabled flag.
  55. */
  56. extern NSString *const kFIRGlobalAppDataCollectionEnabledPlistKey;
  57. /**
  58. * A notification fired containing diagnostic information when SDK errors occur.
  59. */
  60. extern NSString *const kFIRAppDiagnosticsNotification;
  61. /** @var FIRAuthStateDidChangeInternalNotification
  62. @brief The name of the @c NSNotificationCenter notification which is posted when the auth state
  63. changes (e.g. a new token has been produced, a user logs in or out). The object parameter of
  64. the notification is a dictionary possibly containing the key:
  65. @c FIRAuthStateDidChangeInternalNotificationTokenKey (the new access token.) If it does not
  66. contain this key it indicates a sign-out event took place.
  67. */
  68. extern NSString *const FIRAuthStateDidChangeInternalNotification;
  69. /** @var FIRAuthStateDidChangeInternalNotificationTokenKey
  70. @brief A key present in the dictionary object parameter of the
  71. @c FIRAuthStateDidChangeInternalNotification notification. The value associated with this
  72. key will contain the new access token.
  73. */
  74. extern NSString *const FIRAuthStateDidChangeInternalNotificationTokenKey;
  75. /** @var FIRAuthStateDidChangeInternalNotificationAppKey
  76. @brief A key present in the dictionary object parameter of the
  77. @c FIRAuthStateDidChangeInternalNotification notification. The value associated with this
  78. key will contain the FIRApp associated with the auth instance.
  79. */
  80. extern NSString *const FIRAuthStateDidChangeInternalNotificationAppKey;
  81. /** @var FIRAuthStateDidChangeInternalNotificationUIDKey
  82. @brief A key present in the dictionary object parameter of the
  83. @c FIRAuthStateDidChangeInternalNotification notification. The value associated with this
  84. key will contain the new user's UID (or nil if there is no longer a user signed in).
  85. */
  86. extern NSString *const FIRAuthStateDidChangeInternalNotificationUIDKey;
  87. @interface FIRApp ()
  88. /**
  89. * A flag indicating if this is the default app (has the default app name).
  90. */
  91. @property(nonatomic, readonly) BOOL isDefaultApp;
  92. /*
  93. * The container of interop SDKs for this app.
  94. */
  95. @property(nonatomic) FIRComponentContainer *container;
  96. /**
  97. * Creates an error for failing to configure a subspec service. This method is called by each
  98. * FIRApp notification listener.
  99. */
  100. + (NSError *)errorForSubspecConfigurationFailureWithDomain:(NSString *)domain
  101. errorCode:(FIRErrorCode)code
  102. service:(NSString *)service
  103. reason:(NSString *)reason;
  104. /**
  105. * Checks if the default app is configured without trying to configure it.
  106. */
  107. + (BOOL)isDefaultAppConfigured;
  108. /**
  109. * Registers a given third-party library with the given version number to be reported for
  110. * analytics.
  111. *
  112. * @param name Name of the library.
  113. * @param version Version of the library.
  114. */
  115. + (void)registerLibrary:(nonnull NSString *)name withVersion:(nonnull NSString *)version;
  116. /**
  117. * Registers a given internal library with the given version number to be reported for
  118. * analytics.
  119. *
  120. * @param library Optional parameter for component registration.
  121. * @param name Name of the library.
  122. * @param version Version of the library.
  123. */
  124. + (void)registerInternalLibrary:(nonnull Class<FIRLibrary>)library
  125. withName:(nonnull NSString *)name
  126. withVersion:(nonnull NSString *)version;
  127. /**
  128. * A concatenated string representing all the third-party libraries and version numbers.
  129. */
  130. + (NSString *)firebaseUserAgent;
  131. /**
  132. * Used by each SDK to send logs about SDK configuration status to Clearcut.
  133. *
  134. * @note This API is a no-op, please remove calls to it.
  135. */
  136. - (void)sendLogsWithServiceName:(NSString *)serviceName
  137. version:(NSString *)version
  138. error:(NSError *)error;
  139. /**
  140. * Can be used by the unit tests in eack SDK to reset FIRApp. This method is thread unsafe.
  141. */
  142. + (void)resetApps;
  143. /**
  144. * Can be used by the unit tests in each SDK to set customized options.
  145. */
  146. - (instancetype)initInstanceWithName:(NSString *)name options:(FIROptions *)options;
  147. @end
  148. NS_ASSUME_NONNULL_END