ios 如何禁用/删除 FirebaseAnalytics
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37518212/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to disable/remove FirebaseAnalytics
提问by nahung89
I update 'Google/Analytics' from CocoaPod and get FirebaseAnalytics.
我从 CocoaPod 更新“Google/Analytics”并获得 FirebaseAnalytics。
After that, each time I run project, the FirebaseAnalytics turns out many error loggings.
之后,每次我运行项目时,FirebaseAnalytics 都会记录许多错误日志。
Currently I don't use this library and want to remove it. Unfortunately I can't find any way to disable / remove it out of Pod.
目前我不使用这个库并想删除它。不幸的是,我找不到任何方法来禁用/从 Pod 中删除它。
Here is the Podfile configuration
这是Podfile配置
target 'myApp' do
inhibit_all_warnings!
use_frameworks!
pod 'Google/Analytics'
end
Console log:
控制台日志:
<FIRAnalytics/DEBUG> Debug mode is on
<FIRAnalytics/INFO> Firebase Analytics v.3200000 started
<FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see 'https://developer.apple.com/library/ios/recipes/xcode_help-scheme_editor/Articles/SchemeRun.html')
<FIRAnalytics/DEBUG> Debug logging enabled
<FIRAnalytics/DEBUG> Firebase Analytics is monitoring the network status
<FIRAnalytics/DEBUG> Uploading data. Host: https://play.googleapis.com/log
<FIRAnalytics/INFO> Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
<FIRAnalytics/INFO> Firebase Analytics disabled
...
<FIRAnalytics/DEBUG> Network status has changed. code, status: 2, Connected
<FIRAnalytics/DEBUG> Network status has changed. code, status: 2, Connected
<FIRAnalytics/DEBUG> Received SSL challenge for host. Host: https://play.googleapis.com/log
<FIRAnalytics/DEBUG> Cancelling authentication challenge for host. Host: https://play.googleapis.com/log
<FIRAnalytics/ERROR> Encounter network error. Error: Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLKey=https://play.googleapis.com/log, NSLocalizedDescription=cancelled, NSErrorFailingURLStringKey=https://play.googleapis.com/log}
...
UPDATE:I also try to add FirebaseAppDelegateProxyEnabled = false in Info.plist but it doesn't work either.
更新:我也尝试在 Info.plist 中添加 FirebaseAppDelegateProxyEnabled = false 但它也不起作用。
回答by Steve Ganem
To disable the collection of data by Firebase Analytics in your app, see the instructions here.
要在您的应用中禁用 Firebase Analytics 收集数据,请参阅此处的说明。
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.
总之,要暂时禁用,FIREBASE_ANALYTICS_COLLECTION_ENABLED
请NO
在GoogleServices-Info.plist
文件中设置。要永久禁用,FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED
请YES
在同一个 plist 文件中设置为。
回答by Fattie
For 2018
2018年
For 2018, you Info.plist will have entries like this:
对于 2018 年,您的 Info.plist 将有如下条目:
<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, NOTGoogleServices-Info.plist.
它似乎在 Info.plist 中,而不是GoogleServices-Info.plist。
回答by allenh
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.
我最近遇到了类似的问题。我正在使用 Google Analytics,但不想要或不需要 Firebase 分析,如果您遵循docs,它会默认安装。在搜索了 podspecs 之后。我发现Google/Analytics
subspec 依赖于Google/Core
. 子core
规范反过来取决于安装FirebaseAnalytics
它的原因。
I noticed, however, that the Analytics
subspec also depends on the GoogleAnalytics
cocoapods.
然而,我注意到Analytics
subspec 也取决于GoogleAnalytics
cocoapods。
So I changed my Podfile from:
所以我改变了我的 Podfile:
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:
因此,Google/Analytics.h
伞头不再可用,您需要手动包含正确的头或使用以下包含创建自己的伞头:
#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 headerin place of the umbrella header.
如果您在 Swift 项目中执行此操作,则需要将这些文件添加到桥接头中以代替伞头。
In my opinion, this is a small price to pay to not be forced to install the FirebaseAnalytics cocoapod.
在我看来,为了不被强制安装 FirebaseAnalytics cocoapod,这是一个很小的代价。
Update
更新
Although Google's docs haven't been updated, their podspecnow tells you to use the GoogleAnalytics
pod directly
虽然谷歌的文档还没有更新,但他们的podspec现在告诉你GoogleAnalytics
直接使用pod
回答by 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.
这些日志实际上不是来自 Firebase Analytics,而是来自 Firebase Core SDK(基于它发送到的 URL)。因此,禁用 Firebase Analytics 不会消除这些日志。我猜设备网络存在问题,来自 Firebase SDK 的请求被取消。