-
Notifications
You must be signed in to change notification settings - Fork 1.7k
FirebaseApp: send Core Diagnostics data on appDidBecomeActive #3437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
7c8bad9
645d020
69befe3
0964277
991bab7
037e835
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,9 +14,15 @@ | |
|
|
||
| #include <sys/utsname.h> | ||
|
|
||
| #import "FIRApp.h" | ||
| #if __has_include(<UIKit/UIKit.h>) | ||
| #import <UIKit/UIKit.h> | ||
| #endif | ||
|
|
||
| #import <FirebaseCoreDiagnosticsInterop/FIRCoreDiagnosticsData.h> | ||
| #if __has_include(<AppKit/AppKit.h>) | ||
| #import <AppKit/AppKit.h> | ||
| #endif | ||
|
|
||
| #import "FIRApp.h" | ||
|
|
||
| #import "Private/FIRAnalyticsConfiguration.h" | ||
| #import "Private/FIRAppInternal.h" | ||
|
|
@@ -283,15 +289,17 @@ - (instancetype)initInstanceWithName:(NSString *)name options:(FIROptions *)opti | |
| return self; | ||
| } | ||
|
|
||
| - (void)dealloc { | ||
| [[NSNotificationCenter defaultCenter] removeObserver:self]; | ||
| } | ||
|
|
||
| - (BOOL)configureCore { | ||
| [self checkExpectedBundleID]; | ||
| if (![self isAppIDValid]) { | ||
| return NO; | ||
| } | ||
|
|
||
| if ([self isDataCollectionDefaultEnabled]) { | ||
| [FIRCoreDiagnosticsConnector logConfigureCoreWithOptions:_options]; | ||
| } | ||
| [self logDiagnostics]; | ||
|
|
||
| #if TARGET_OS_IOS | ||
| // Initialize the Analytics once there is a valid options under default app. Analytics should | ||
|
|
@@ -316,6 +324,8 @@ - (BOOL)configureCore { | |
| } | ||
| #endif | ||
|
|
||
| [self subscribeForAppDidBecomeActiveNotifications]; | ||
|
|
||
| return YES; | ||
| } | ||
|
|
||
|
|
@@ -796,4 +806,31 @@ - (void)sendLogsWithServiceName:(NSString *)serviceName | |
| } | ||
| #pragma clang diagnostic pop | ||
|
|
||
| #pragma mark - App Life Cycle | ||
|
|
||
| - (void)subscribeForAppDidBecomeActiveNotifications { | ||
| #if TARGET_OS_IOS || TARGET_OS_TV | ||
| NSNotificationName notificationName = UIApplicationDidBecomeActiveNotification; | ||
| #endif | ||
|
|
||
| #if TARGET_OS_OSX | ||
| NSNotificationName notificationName = NSApplicationDidBecomeActiveNotification; | ||
| #endif | ||
|
|
||
| [[NSNotificationCenter defaultCenter] addObserver:self | ||
| selector:@selector(appDidBecomeActive:) | ||
| name:notificationName | ||
| object:nil]; | ||
| } | ||
|
|
||
| - (void)appDidBecomeActive:(NSNotification *)notification { | ||
| [self logDiagnostics]; | ||
| } | ||
|
|
||
| - (void)logDiagnostics { | ||
| if ([self isDataCollectionDefaultEnabled]) { | ||
| [FIRCoreDiagnosticsConnector logConfigureCoreWithOptions:_options]; | ||
|
||
| } | ||
| } | ||
|
|
||
| @end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI, there is some lifecycle code in GDTLifecycle. I'm not sure if you want to adopt that protocol or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be nice to reuse it. Is
GoogleDataTransportmeant to be a required dependency for FirebaseCore?cc @paulb777
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GDT won't come in if FirebaseCoreDiagnostics isn't present, so I wouldn't add a hard dependency on it.