FIRAppInternal.h 5.9 KB

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