FIRAppInternal.h 5.7 KB

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