我从 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 收集数据,请参阅此处的说明。
总之,要暂时禁用,请在
FIREBASE_ANALYTICS_COLLECTION_ENABLED
文件中将 NO
设置为 GoogleServices-Info.plist
。要永久禁用,请在同一 plist 文件中将 FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED
设置为 YES
。
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。
我最近遇到了类似的问题。我正在使用 Google Analytics,但不想要或不需要 Firebase 分析,如果您遵循 docs,默认情况下会安装 Firebase 分析。搜索 podspec 后。我发现
Google/Analytics
子规范依赖于 Google/Core
。 core
子规范又取决于 FirebaseAnalytics
,这就是安装它的原因。
但是,我注意到
Analytics
子规格也取决于 GoogleAnalytics
cocoapods。
所以我将 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
伞形标题不再可用,您需要手动包含正确的标题或使用以下内容创建自己的伞形标题:
#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 来代替伞形标头。
在我看来,为了不被迫安装 FirebaseAnalytics cocoapod,这是一个很小的代价。
虽然 Google 的文档尚未更新,但他们的 podspec 现在告诉你直接使用
GoogleAnalytics
pod
这些日志实际上并非来自 Firebase Analytics,而是来自 Firebase Core SDK(基于其发送到的 URL)。因此,禁用 Firebase Analytics 不会消除这些日志。我猜想设备网络出现问题,导致 Firebase SDK 的请求被取消。
将 Android 平台的 Google Analytics 设置为 true
<meta-data
android:name="firebase_analytics_collection_enabled"
android:value="true" />