FIRAnalyticsConfiguration.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 <Foundation/Foundation.h>
  17. /// Values stored in analyticsEnabledState. Never alter these constants since they must match with
  18. /// values persisted to disk.
  19. typedef NS_ENUM(int64_t, FIRAnalyticsEnabledState) {
  20. // 0 is the default value for keys not found stored in persisted config, so it cannot represent
  21. // kFIRAnalyticsEnabledStateSetNo. It must represent kFIRAnalyticsEnabledStateNotSet.
  22. kFIRAnalyticsEnabledStateNotSet = 0,
  23. kFIRAnalyticsEnabledStateSetYes = 1,
  24. kFIRAnalyticsEnabledStateSetNo = 2,
  25. };
  26. /// The user defaults key for the persisted measurementEnabledState value. FIRAPersistedConfig reads
  27. /// measurementEnabledState using this same key.
  28. static NSString *const kFIRAPersistedConfigMeasurementEnabledStateKey =
  29. @"/google/measurement/measurement_enabled_state";
  30. static NSString *const kFIRAnalyticsConfigurationSetEnabledNotification =
  31. @"FIRAnalyticsConfigurationSetEnabledNotification";
  32. static NSString *const kFIRAnalyticsConfigurationSetMinimumSessionIntervalNotification =
  33. @"FIRAnalyticsConfigurationSetMinimumSessionIntervalNotification";
  34. static NSString *const kFIRAnalyticsConfigurationSetSessionTimeoutIntervalNotification =
  35. @"FIRAnalyticsConfigurationSetSessionTimeoutIntervalNotification";
  36. @interface FIRAnalyticsConfiguration : NSObject
  37. /// Returns the shared instance of FIRAnalyticsConfiguration.
  38. + (FIRAnalyticsConfiguration *)sharedInstance;
  39. // Sets whether analytics collection is enabled for this app on this device. This setting is
  40. // persisted across app sessions. By default it is enabled.
  41. - (void)setAnalyticsCollectionEnabled:(BOOL)analyticsCollectionEnabled;
  42. /// Sets whether analytics collection is enabled for this app on this device, and a flag to persist
  43. /// the value or not. The setting should not be persisted if being set by the global data collection
  44. /// flag.
  45. - (void)setAnalyticsCollectionEnabled:(BOOL)analyticsCollectionEnabled
  46. persistSetting:(BOOL)shouldPersist;
  47. @end