Completely disable Firebase/Analytics to stop console spam on app startup

本秂侑毒 提交于 2019-11-27 16:02:44

问题


I've installed Google/SignIn cocoapod into my application (which I need to support GoogleDrive), but it depends on Google/Core which depends on FirebaseAnalytics. I don't want or need FirebaseAnalytics.

FirebaseAnalytics spams the developer console with 8 lines of output when our app starts:

2017-06-07 18:07:19.612994+0100 son[2909:877661] [Firebase/Analytics][I-ACS005000] The AdSupport Framework is not currently linked. Some features will not function properly. Learn more at http://gooX.gl/9vSsPb
2017-06-07 18:07:19.613 son[2909] <Warning> [Firebase/Analytics][I-ACS005000] The AdSupport Framework is not currently linked. Some features will not function properly. Learn more at http://gooX.gl/9vSsPb
2017-06-07 18:07:19.613896+0100 son[2909:877661] [Firebase/Analytics][I-ACS023007] Firebase Analytics v.3900000 started
2017-06-07 18:07:19.614 son[2909] <Notice> [Firebase/Analytics][I-ACS023007] Firebase Analytics v.3900000 started
2017-06-07 18:07:19.614525+0100 son[2909:877661] [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://gooX.gl/RfcP7r)
2017-06-07 18:07:19.614 son[2909] <Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://gooX.gl/RfcP7r)
2017-06-07 18:07:19.622560+0100 son[2909:877662] [Firebase/Analytics][I-ACS023013] Firebase Analytics disabled
2017-06-07 18:07:19.623 son[2909] <Notice> [Firebase/Analytics][I-ACS023013] Firebase Analytics disabled

(I had to add X to the URLs in the above output to get past stackoverflow's URL shortener blocker.)

I tried setting FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED to YES in my Info.plist, that removed 2 lines, but added another 2 lines to tell me that Analytics is disabled (FFS!).

This spammed output makes it difficult for our developers to see any console output that is actually important. How can I disable it?

(Failing that, a suggestion on how to get it outputting each line only once would be really welcome.)


回答1:


You can find this buried in the output:

<Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging
 set the following application argument: -FIRAnalyticsDebugEnabled

Disabling is the opposite - set the argument: -noFIRAnalyticsDebugEnabled:

Additionally, you can control the default Firebase logging level with the setLoggerLevel method in FIRConfiguration. For example to disable all Firebase logging:

  [[FIRConfiguration sharedInstance] setLoggerLevel:FIRLoggerLevelMin];
  [FIRApp configure];

or in Swift:

FirebaseConfiguration.shared.setLoggerLevel(FirebaseLoggerLevel.min)
FirebaseApp.configure()

More details in the FIRLogger implementation here




回答2:


To the best of my knowledge, these two lines:

[[FIRConfiguration sharedInstance] setLoggerLevel:FIRLoggerLevelMin];
[[FIRAnalyticsConfiguration sharedInstance] setAnalyticsCollectionEnabled:NO];

placed very early in the app delegate's didFinishLaunchingWithOptions: will completely disable FireBase analytics, including stopping all the console output.

I've also since discovered that the Google/SignIn cocoapod is deprecated - the recommended one to use is GoogleSignIn (ie. no '/'). If you use GoogleSignIn, then this doesn't have a dependency on Firebase Analytics, so the original problem goes away. Now I have Google Drive support in my app and don't have Firebase Analytics!




回答3:


Swift 4.0:

FirebaseConfiguration.shared.setLoggerLevel(.min) FirebaseConfiguration.shared.analyticsConfiguration.setAnalyticsCollectionEnabled(false)



来源:https://stackoverflow.com/questions/44419076/completely-disable-firebase-analytics-to-stop-console-spam-on-app-startup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!