aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firebase
diff options
context:
space:
mode:
authorGravatar Zsika Phillip <protocol86@users.noreply.github.com>2017-09-12 18:29:44 -0700
committerGravatar GitHub <noreply@github.com>2017-09-12 18:29:44 -0700
commit660f62778ab246c66da5442bc3bd8dadf301b328 (patch)
tree168625107739c69904017090318c53e86c4afa80 /Firebase
parent1c44d3914609c4253f8d046f0671059de5219b1c (diff)
Adds ability to track Firebase Auth UI per request (#251)
* Adds ability to track Firebase Auth UI per request Adds internal method to FIRAuth which will be accessed in Auth UI via an extension. Example request header header with Firebase Auth Core Marker: X-Client-Version: iOS/FirebaseSDK/0.1.1/FirebaseCore-iOS
Diffstat (limited to 'Firebase')
-rw-r--r--Firebase/Auth/Source/FIRAuth.m23
-rw-r--r--Firebase/Auth/Source/RPCs/FIRAuthBackend.m12
-rw-r--r--Firebase/Auth/Source/RPCs/FIRAuthRequestConfiguration.h5
3 files changed, 36 insertions, 4 deletions
diff --git a/Firebase/Auth/Source/FIRAuth.m b/Firebase/Auth/Source/FIRAuth.m
index dd0b0bf..8d29eb2 100644
--- a/Firebase/Auth/Source/FIRAuth.m
+++ b/Firebase/Auth/Source/FIRAuth.m
@@ -202,6 +202,11 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
*/
@property(nonatomic, copy, readonly) NSString *firebaseAppId;
+/** @property additionalFrameworkMarker
+ @brief Additional framework marker that will be added as part of the header of every request.
+ */
+@property(nonatomic, copy, nullable) NSString *additionalFrameworkMarker;
+
/** @fn initWithApp:
@brief Creates a @c FIRAuth instance associated with the provided @c FIRApp instance.
@param app The application to associate the auth instance with.
@@ -945,7 +950,9 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
}
- (void)useAppLanguage {
- _requestConfiguration.languageCode = [NSBundle mainBundle].preferredLocalizations.firstObject;
+ dispatch_sync(FIRAuthGlobalWorkQueue(), ^{
+ _requestConfiguration.languageCode = [NSBundle mainBundle].preferredLocalizations.firstObject;
+ });
}
- (nullable NSString *)languageCode {
@@ -953,7 +960,19 @@ static NSMutableDictionary *gKeychainServiceNameForAppName;
}
- (void)setLanguageCode:(nullable NSString *)languageCode {
- _requestConfiguration.languageCode = [languageCode copy];
+ dispatch_sync(FIRAuthGlobalWorkQueue(), ^{
+ _requestConfiguration.languageCode = [languageCode copy];
+ });
+}
+
+- (NSString *)additionalFrameworkMarker {
+ return _requestConfiguration.additionalFrameworkMarker;
+}
+
+- (void)setAdditionalFrameworkMarker:(NSString *)additionalFrameworkMarker {
+ dispatch_sync(FIRAuthGlobalWorkQueue(), ^{
+ _requestConfiguration.additionalFrameworkMarker = [additionalFrameworkMarker copy];
+ });
}
#if TARGET_OS_IOS
diff --git a/Firebase/Auth/Source/RPCs/FIRAuthBackend.m b/Firebase/Auth/Source/RPCs/FIRAuthBackend.m
index 2a70a80..2442882 100644
--- a/Firebase/Auth/Source/RPCs/FIRAuthBackend.m
+++ b/Firebase/Auth/Source/RPCs/FIRAuthBackend.m
@@ -76,6 +76,11 @@ static NSString *const kIosBundleIdentifierHeader = @"X-Ios-Bundle-Identifier";
*/
static NSString *const kFirebaseLocalHeader = @"X-Firebase-Locale";
+/** @var kFirebaseAuthCoreFrameworkMarker
+ @brief The marker in the HTTP header that indicates the request comes from Firebase Auth Core.
+ */
+static NSString *const kFirebaseAuthCoreFrameworkMarker = @"FirebaseCore-iOS";
+
/** @var kJSONContentType
@brief The value of the HTTP content-type header for JSON payloads.
*/
@@ -499,8 +504,11 @@ static id<FIRAuthBackendImplementation> gBackendImplementation;
NSError *_Nullable))handler {
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
[request setValue:contentType forHTTPHeaderField:@"Content-Type"];
- NSString *clientVersion =
- [NSString stringWithFormat:@"iOS/FirebaseSDK/%s", FirebaseAuthVersionString];
+ NSString *additionalFrameworkMarker = requestConfiguration.additionalFrameworkMarker ?:
+ kFirebaseAuthCoreFrameworkMarker;
+ NSString *clientVersion = [NSString stringWithFormat:@"iOS/FirebaseSDK/%s/%@",
+ FirebaseAuthVersionString,
+ additionalFrameworkMarker];
[request setValue:clientVersion forHTTPHeaderField:kClientVersionHeader];
NSString *bundleID = [[NSBundle mainBundle] bundleIdentifier];
[request setValue:bundleID forHTTPHeaderField:kIosBundleIdentifierHeader];
diff --git a/Firebase/Auth/Source/RPCs/FIRAuthRequestConfiguration.h b/Firebase/Auth/Source/RPCs/FIRAuthRequestConfiguration.h
index 1aec6f6..f24f23a 100644
--- a/Firebase/Auth/Source/RPCs/FIRAuthRequestConfiguration.h
+++ b/Firebase/Auth/Source/RPCs/FIRAuthRequestConfiguration.h
@@ -35,6 +35,11 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property(nonatomic, copy, nullable) NSString *languageCode;
+/** @property additionalFrameworkMarker
+ @brief Additional framework marker that will be added as part of the header of every request.
+ */
+@property(nonatomic, copy, nullable) NSString *additionalFrameworkMarker;
+
- (nullable instancetype)init NS_UNAVAILABLE;
/** @fn initWithRequestClass:APIKey:authLanguage: