No Description

FIRDiagnosticsData.m 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright 2019 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 "Private/FIRDiagnosticsData.h"
  17. #import <FirebaseCore/FIRApp.h>
  18. #import "Private/FIRAppInternal.h"
  19. #import "Private/FIROptionsInternal.h"
  20. @implementation FIRDiagnosticsData {
  21. /** Backing ivar for the diagnosticObjects property. */
  22. NSMutableDictionary<NSString *, id> *_diagnosticObjects;
  23. }
  24. - (instancetype)init {
  25. self = [super init];
  26. if (self) {
  27. _diagnosticObjects = [[NSMutableDictionary alloc] init];
  28. }
  29. return self;
  30. }
  31. - (void)insertValue:(nullable id)value forKey:(NSString *)key {
  32. if (key) {
  33. _diagnosticObjects[key] = value;
  34. }
  35. }
  36. #pragma mark - FIRCoreDiagnosticsData
  37. - (NSDictionary<NSString *, id> *)diagnosticObjects {
  38. if (!_diagnosticObjects[kFIRCDllAppsCountKey]) {
  39. _diagnosticObjects[kFIRCDllAppsCountKey] = @([FIRApp allApps].count);
  40. }
  41. if (!_diagnosticObjects[kFIRCDIsDataCollectionDefaultEnabledKey]) {
  42. _diagnosticObjects[kFIRCDIsDataCollectionDefaultEnabledKey] =
  43. @([[FIRApp defaultApp] isDataCollectionDefaultEnabled]);
  44. }
  45. if (!_diagnosticObjects[kFIRCDFirebaseUserAgentKey]) {
  46. _diagnosticObjects[kFIRCDFirebaseUserAgentKey] = [FIRApp firebaseUserAgent];
  47. }
  48. return _diagnosticObjects;
  49. }
  50. #pragma clang diagnostic push
  51. #pragma clang diagnostic ignored "-Wunused-parameter"
  52. - (void)setDiagnosticObjects:(NSDictionary<NSString *, id> *)diagnosticObjects {
  53. NSAssert(NO, @"Please use -insertValue:forKey:");
  54. }
  55. #pragma clang diagnostic pop
  56. @end