2 * Copyright 2017 Google
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 @class FIRComponentContainer;
21 @protocol FIRCoreConfigurable;
24 * The internal interface to FIRApp. This is meant for first-party integrators, who need to receive
25 * FIRApp notifications, log info about the success or failure of their configuration, and access
26 * other internal functionality of FIRApp.
28 * TODO(b/28296561): Restructure this header.
30 NS_ASSUME_NONNULL_BEGIN
32 typedef NS_ENUM(NSInteger, FIRConfigType) {
33 FIRConfigTypeCore = 1,
38 * Names of services provided by Firebase.
40 extern NSString *const kFIRServiceAdMob;
41 extern NSString *const kFIRServiceAuth;
42 extern NSString *const kFIRServiceAuthUI;
43 extern NSString *const kFIRServiceCrash;
44 extern NSString *const kFIRServiceDatabase;
45 extern NSString *const kFIRServiceDynamicLinks;
46 extern NSString *const kFIRServiceInstanceID;
47 extern NSString *const kFIRServiceInvites;
48 extern NSString *const kFIRServiceMessaging;
49 extern NSString *const kFIRServiceMeasurement;
50 extern NSString *const kFIRServiceRemoteConfig;
51 extern NSString *const kFIRServiceStorage;
54 * Names of services provided by the Google pod, but logged by the Firebase pod.
56 extern NSString *const kGGLServiceAnalytics;
57 extern NSString *const kGGLServiceSignIn;
59 extern NSString *const kFIRDefaultAppName;
60 extern NSString *const kFIRAppReadyToConfigureSDKNotification;
61 extern NSString *const kFIRAppDeleteNotification;
62 extern NSString *const kFIRAppIsDefaultAppKey;
63 extern NSString *const kFIRAppNameKey;
64 extern NSString *const kFIRGoogleAppIDKey;
67 * The format string for the User Defaults key used for storing the data collection enabled flag.
68 * This includes formatting to append the Firebase App's name.
70 extern NSString *const kFIRGlobalAppDataCollectionEnabledDefaultsKeyFormat;
73 * The plist key used for storing the data collection enabled flag.
75 extern NSString *const kFIRGlobalAppDataCollectionEnabledPlistKey;
78 * A notification fired containing diagnostic information when SDK errors occur.
80 extern NSString *const kFIRAppDiagnosticsNotification;
82 /** @var FIRAuthStateDidChangeInternalNotification
83 @brief The name of the @c NSNotificationCenter notification which is posted when the auth state
84 changes (e.g. a new token has been produced, a user logs in or out). The object parameter of
85 the notification is a dictionary possibly containing the key:
86 @c FIRAuthStateDidChangeInternalNotificationTokenKey (the new access token.) If it does not
87 contain this key it indicates a sign-out event took place.
89 extern NSString *const FIRAuthStateDidChangeInternalNotification;
91 /** @var FIRAuthStateDidChangeInternalNotificationTokenKey
92 @brief A key present in the dictionary object parameter of the
93 @c FIRAuthStateDidChangeInternalNotification notification. The value associated with this
94 key will contain the new access token.
96 extern NSString *const FIRAuthStateDidChangeInternalNotificationTokenKey;
98 /** @var FIRAuthStateDidChangeInternalNotificationAppKey
99 @brief A key present in the dictionary object parameter of the
100 @c FIRAuthStateDidChangeInternalNotification notification. The value associated with this
101 key will contain the FIRApp associated with the auth instance.
103 extern NSString *const FIRAuthStateDidChangeInternalNotificationAppKey;
105 /** @var FIRAuthStateDidChangeInternalNotificationUIDKey
106 @brief A key present in the dictionary object parameter of the
107 @c FIRAuthStateDidChangeInternalNotification notification. The value associated with this
108 key will contain the new user's UID (or nil if there is no longer a user signed in).
110 extern NSString *const FIRAuthStateDidChangeInternalNotificationUIDKey;
112 /** @typedef FIRTokenCallback
113 @brief The type of block which gets called when a token is ready.
115 typedef void (^FIRTokenCallback)(NSString *_Nullable token, NSError *_Nullable error);
117 /** @typedef FIRAppGetTokenImplementation
118 @brief The type of block which can provide an implementation for the @c getTokenWithCallback:
120 @param forceRefresh Forces the token to be refreshed.
121 @param callback The block which should be invoked when the async call completes.
123 typedef void (^FIRAppGetTokenImplementation)(BOOL forceRefresh, FIRTokenCallback callback);
125 /** @typedef FIRAppGetUID
126 @brief The type of block which can provide an implementation for the @c getUID method.
128 typedef NSString *_Nullable (^FIRAppGetUIDImplementation)(void);
133 * A flag indicating if this is the default app.
135 @property(nonatomic, readonly) BOOL isDefaultApp;
137 /** @property getTokenImplementation
138 @brief Gets or sets the block to use for the implementation of
139 @c getTokenForcingRefresh:withCallback:
141 @property(nonatomic, copy) FIRAppGetTokenImplementation getTokenImplementation;
143 /** @property getUIDImplementation
144 @brief Gets or sets the block to use for the implementation of @c getUID.
146 @property(nonatomic, copy) FIRAppGetUIDImplementation getUIDImplementation;
149 * The container of interop SDKs for this app.
151 @property(nonatomic) FIRComponentContainer *container;
154 * Creates an error for failing to configure a subspec service. This method is called by each
155 * FIRApp notification listener.
157 + (NSError *)errorForSubspecConfigurationFailureWithDomain:(NSString *)domain
158 errorCode:(FIRErrorCode)code
159 service:(NSString *)service
160 reason:(NSString *)reason;
162 * Checks if the default app is configured without trying to configure it.
164 + (BOOL)isDefaultAppConfigured;
167 * Register a class that conforms to `FIRCoreConfigurable`. Each SDK should have one class that
168 * registers in order to provide critical information for interoperability and lifecycle events.
169 * TODO(wilsonryan): Write more documentation.
171 + (void)registerAsConfigurable:(Class<FIRCoreConfigurable>)klass;
174 * Registers a given third-party library with the given version number to be reported for
177 * @param library Name of the library
178 * @param version Version of the library
181 + (void)registerLibrary:(NSString *)library
182 withVersion:(NSString *)version NS_SWIFT_NAME(registerLibrary(_:version:));
186 * A concatenated string representing all the third-party libraries and version numbers.
188 + (NSString *)firebaseUserAgent;
191 * Used by each SDK to send logs about SDK configuration status to Clearcut.
193 - (void)sendLogsWithServiceName:(NSString *)serviceName
194 version:(NSString *)version
195 error:(NSError *)error;
198 * Can be used by the unit tests in eack SDK to reset FIRApp. This method is thread unsafe.
203 * Can be used by the unit tests in each SDK to set customized options.
205 - (instancetype)initInstanceWithName:(NSString *)name options:(FIROptions *)options;
207 /** @fn getTokenForcingRefresh:withCallback:
208 @brief Retrieves the Firebase authentication token, possibly refreshing it.
209 @param forceRefresh Forces a token refresh. Useful if the token becomes invalid for some reason
210 other than an expiration.
211 @param callback The block to invoke when the token is available.
213 - (void)getTokenForcingRefresh:(BOOL)forceRefresh withCallback:(FIRTokenCallback)callback;
216 * Expose the UID of the current user for Firestore.
218 - (nullable NSString *)getUID;
222 NS_ASSUME_NONNULL_END