如何 disable/remove FirebaseAnalytics
How to disable/remove FirebaseAnalytics
我从 CocoaPod 更新 'Google/Analytics' 并获取 FirebaseAnalytics。
之后,每次我 运行 项目时,FirebaseAnalytics 都会输出很多错误日志。
目前我不使用这个库,想删除它。不幸的是,我找不到任何方法将其从 Pod 中禁用/删除。
这里是 Podfile 配置
target 'myApp' do
inhibit_all_warnings!
use_frameworks!
pod 'Google/Analytics'
end
控制台日志:
<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}
...
更新:
我也尝试在 Info.plist 中添加 FirebaseAppDelegateProxyEnabled = false 但它也不起作用。
要在您的应用中禁用 Firebase Analytics 收集数据,请参阅说明 here。
总而言之,要暂时禁用,请在 GoogleServices-Info.plist
文件中将 FIREBASE_ANALYTICS_COLLECTION_ENABLED
设置为 NO
。要永久禁用,请在同一 plist 文件中将 FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED
设置为 YES
。
这些日志实际上不是来自 Firebase Analytics,而是来自 Firebase Core SDK(基于它发送到的 URL)。因此,禁用 Firebase Analytics 不会消除这些日志。估计是设备网络有问题导致Firebase SDK的请求被取消了
我最近 运行 遇到了类似的问题。我正在使用 Google Analytics,但不想或不需要 Firebase 分析,如果您遵循 docs,默认情况下会安装它。在搜索 podspecs 之后。我发现 Google/Analytics
子规范依赖于 Google/Core
。 core
子规范又取决于 FirebaseAnalytics
,这就是安装它的原因。
然而,我注意到 Analytics
子规格也依赖于 GoogleAnalytics
椰子足类。
所以我将我的 Podfile 更改为:
target 'myApp' do
inhibit_all_warnings!
use_frameworks!
pod 'Google/Analytics'
end
为此:
target 'myApp' do
inhibit_all_warnings!
use_frameworks!
pod 'GoogleAnalytics'
end
因此,Google/Analytics.h
伞 header 不再可用,您需要手动添加正确的 header 或创建您自己的伞 header其中包括:
#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"
如果您在 Swift 项目中执行此操作,则需要将这些文件添加到您的 bridging header 中以代替 header.
在我看来,为了不被迫安装 FirebaseAnalytics cocoapod,这是一个很小的代价。
更新
尽管 Google 的文档尚未更新,但他们的 podspec 现在告诉您直接使用 GoogleAnalytics
pod
2018 年
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/>
它似乎在 Info.plist,不是 GoogleServices-Info.plist。
我从 CocoaPod 更新 'Google/Analytics' 并获取 FirebaseAnalytics。
之后,每次我 运行 项目时,FirebaseAnalytics 都会输出很多错误日志。
目前我不使用这个库,想删除它。不幸的是,我找不到任何方法将其从 Pod 中禁用/删除。
这里是 Podfile 配置
target 'myApp' do
inhibit_all_warnings!
use_frameworks!
pod 'Google/Analytics'
end
控制台日志:
<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}
...
更新: 我也尝试在 Info.plist 中添加 FirebaseAppDelegateProxyEnabled = false 但它也不起作用。
要在您的应用中禁用 Firebase Analytics 收集数据,请参阅说明 here。
总而言之,要暂时禁用,请在 GoogleServices-Info.plist
文件中将 FIREBASE_ANALYTICS_COLLECTION_ENABLED
设置为 NO
。要永久禁用,请在同一 plist 文件中将 FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED
设置为 YES
。
这些日志实际上不是来自 Firebase Analytics,而是来自 Firebase Core SDK(基于它发送到的 URL)。因此,禁用 Firebase Analytics 不会消除这些日志。估计是设备网络有问题导致Firebase SDK的请求被取消了
我最近 运行 遇到了类似的问题。我正在使用 Google Analytics,但不想或不需要 Firebase 分析,如果您遵循 docs,默认情况下会安装它。在搜索 podspecs 之后。我发现 Google/Analytics
子规范依赖于 Google/Core
。 core
子规范又取决于 FirebaseAnalytics
,这就是安装它的原因。
然而,我注意到 Analytics
子规格也依赖于 GoogleAnalytics
椰子足类。
所以我将我的 Podfile 更改为:
target 'myApp' do
inhibit_all_warnings!
use_frameworks!
pod 'Google/Analytics'
end
为此:
target 'myApp' do
inhibit_all_warnings!
use_frameworks!
pod 'GoogleAnalytics'
end
因此,Google/Analytics.h
伞 header 不再可用,您需要手动添加正确的 header 或创建您自己的伞 header其中包括:
#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"
如果您在 Swift 项目中执行此操作,则需要将这些文件添加到您的 bridging header 中以代替 header.
在我看来,为了不被迫安装 FirebaseAnalytics cocoapod,这是一个很小的代价。
更新
尽管 Google 的文档尚未更新,但他们的 podspec 现在告诉您直接使用 GoogleAnalytics
pod
2018 年
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/>
它似乎在 Info.plist,不是 GoogleServices-Info.plist。