How to disable/remove FirebaseAnalytics

巧了我就是萌 提交于 2019-11-26 22:51:42
Steve Ganem

To disable the collection of data by Firebase Analytics in your app, see the instructions here.

In summary, to disable temporarily, set FIREBASE_ANALYTICS_COLLECTION_ENABLED to NO in the GoogleServices-Info.plist file. To disable permanently, set FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED to YES in the same plist file.

For 2018

For 2018, you Info.plist will have entries like this:

<key>FIREBASE_ANALYTICS_COLLECTION_ENABLED</key>
<string>NO</string>
<key>FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED</key>
<string>YES</string>
<key>FirebaseScreenReportingEnabled</key>
<false/>

It seems to be in Info.plist, NOT GoogleServices-Info.plist.

I recently ran into a similar issue. I'm using Google Analytics but do not want or need Firebase analytics, which is installed by default if you follow the docs. After searching through the podspecs. I found that the Google/Analytics subspec has a dependency on Google/Core. The core subspec in turn depends on FirebaseAnalytics which is why it is getting installed.

I noticed, however, that the Analytics subspec also depends on the GoogleAnalytics cocoapods.

So I changed my Podfile from:

target 'myApp' do
    inhibit_all_warnings!
    use_frameworks!
    pod 'Google/Analytics'
end

To this:

target 'myApp' do
    inhibit_all_warnings!
    use_frameworks!
    pod 'GoogleAnalytics'
end

As a result, the Google/Analytics.h umbrella header is no longer available, and you need to include the correct headers manually or create your own umbrella header with the following includes:

#import "GAI.h"
#import "GAIDictionaryBuilder.h"
#import "GAIEcommerceFields.h"
#import "GAIEcommerceProduct.h"
#import "GAIEcommerceProductAction.h"
#import "GAIEcommercePromotion.h"
#import "GAIFields.h"
#import "GAILogger.h"
#import "GAITrackedViewController.h"
#import "GAITracker.h"

If you're doing this in a Swift project, you'll need to add these files to your bridging header in place of the umbrella header.

In my opinion, this is a small price to pay to not be forced to install the FirebaseAnalytics cocoapod.

Update

Although Google's docs haven't been updated, their podspec now tells you to use the GoogleAnalytics pod directly

adbitx

Those logs are not actually from Firebase Analytics but the Firebase Core SDK (based on the URL that it sent to). Therefore, disabling the Firebase Analytics will not eliminate those logs. I guess there was a problem with the device network that the requests from Firebase SDK were cancelled.

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