Proyectos de Subversion Iphone Microlearning

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 
17
#import "FirebaseCore/Sources/Private/FIRCoreDiagnosticsConnector.h"
18
 
19
#import "Interop/CoreDiagnostics/Public/FIRCoreDiagnosticsInterop.h"
20
 
21
#import "FirebaseCore/Sources/Public/FirebaseCore/FIROptions.h"
22
 
23
#import "FirebaseCore/Sources/FIRDiagnosticsData.h"
24
#import "FirebaseCore/Sources/Private/FIRAppInternal.h"
25
#import "FirebaseCore/Sources/Private/FIROptionsInternal.h"
26
 
27
// Define the interop class symbol declared as an extern in FIRCoreDiagnosticsInterop.
28
Class<FIRCoreDiagnosticsInterop> FIRCoreDiagnosticsImplementation;
29
 
30
@implementation FIRCoreDiagnosticsConnector
31
 
32
+ (void)initialize {
33
  if (!FIRCoreDiagnosticsImplementation) {
34
    FIRCoreDiagnosticsImplementation = NSClassFromString(@"FIRCoreDiagnostics");
35
    if (FIRCoreDiagnosticsImplementation) {
36
      NSAssert([FIRCoreDiagnosticsImplementation
37
                   conformsToProtocol:@protocol(FIRCoreDiagnosticsInterop)],
38
               @"If FIRCoreDiagnostics is implemented, it must conform to the interop protocol.");
39
      NSAssert(
40
          [FIRCoreDiagnosticsImplementation respondsToSelector:@selector(sendDiagnosticsData:)],
41
          @"If FIRCoreDiagnostics is implemented, it must implement +sendDiagnosticsData.");
42
    }
43
  }
44
}
45
 
46
+ (void)logCoreTelemetryWithOptions:(FIROptions *)options {
47
  if (FIRCoreDiagnosticsImplementation) {
48
    FIRDiagnosticsData *diagnosticsData = [[FIRDiagnosticsData alloc] init];
49
    [diagnosticsData insertValue:@(YES) forKey:kFIRCDIsDataCollectionDefaultEnabledKey];
50
    [diagnosticsData insertValue:[FIRApp firebaseUserAgent] forKey:kFIRCDFirebaseUserAgentKey];
51
    [diagnosticsData insertValue:@(FIRConfigTypeCore) forKey:kFIRCDConfigurationTypeKey];
52
    [diagnosticsData insertValue:options.googleAppID forKey:kFIRCDGoogleAppIDKey];
53
    [diagnosticsData insertValue:options.bundleID forKey:kFIRCDBundleIDKey];
54
    [diagnosticsData insertValue:@(options.usingOptionsFromDefaultPlist)
55
                          forKey:kFIRCDUsingOptionsFromDefaultPlistKey];
56
    [diagnosticsData insertValue:options.libraryVersionID forKey:kFIRCDLibraryVersionIDKey];
57
    [FIRCoreDiagnosticsImplementation sendDiagnosticsData:diagnosticsData];
58
  }
59
}
60
 
61
@end