aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firebase/Core/FIRApp.m
diff options
context:
space:
mode:
authorGravatar Ryan Wilson <wilsonryan@google.com>2018-05-21 21:49:57 -0400
committerGravatar GitHub <noreply@github.com>2018-05-21 21:49:57 -0400
commit503d2debdddd85331ce2e8556bbd50d53f3aa19d (patch)
tree609f6d8a584f91c081f5b80d383b46d3234ef813 /Firebase/Core/FIRApp.m
parent11933c038df81f57c0e7d15f5a8795b74e874843 (diff)
Add conformance to data collection switch for Analytics. (#1296)
* Add conformance to data collection switch for Analytics. * Fix method documentation per PR comments.
Diffstat (limited to 'Firebase/Core/FIRApp.m')
-rw-r--r--Firebase/Core/FIRApp.m18
1 files changed, 18 insertions, 0 deletions
diff --git a/Firebase/Core/FIRApp.m b/Firebase/Core/FIRApp.m
index 717da4e..b295d50 100644
--- a/Firebase/Core/FIRApp.m
+++ b/Firebase/Core/FIRApp.m
@@ -16,6 +16,7 @@
#import "FIRApp.h"
#import "FIRConfiguration.h"
+#import "Private/FIRAnalyticsConfiguration+Internal.h"
#import "Private/FIRAppInternal.h"
#import "Private/FIRBundleUtil.h"
#import "Private/FIRLogger.h"
@@ -342,6 +343,23 @@ static NSMutableDictionary *sLibraryVersions;
NSString *key =
[NSString stringWithFormat:kFIRGlobalAppDataCollectionEnabledDefaultsKeyFormat, self.name];
[[NSUserDefaults standardUserDefaults] setBool:automaticDataCollectionEnabled forKey:key];
+
+ // Core also controls the FirebaseAnalytics flag, so check if the Analytics flags are set
+ // within FIROptions and change the Analytics value if necessary. Analytics only works with the
+ // default app, so return if this isn't the default app.
+ if (self != sDefaultApp) {
+ return;
+ }
+
+ // Check if the Analytics flag is explicitly set. If so, no further actions are necessary.
+ if ([self.options isAnalyticsCollectionExpicitlySet]) {
+ return;
+ }
+
+ // The Analytics flag has not been explicitly set, so update with the value being set.
+ [[FIRAnalyticsConfiguration sharedInstance]
+ setAnalyticsCollectionEnabled:automaticDataCollectionEnabled
+ persistSetting:NO];
}
- (BOOL)isAutomaticDataCollectionEnabled {