为什么 FirebaseAnalytics.ConsentType ANALYTICS_STORAGE 默认被拒绝?

Why is FirebaseAnalytics.ConsentType ANALYTICS_STORAGE denied by default?

我将 firebase analytics 升级到 v18.0.2 之后,我无法再使用 getAppInstanceId 获取应用程序实例 ID,我开始获取 null。

根据 getAppInstanceId

的文档

Retrieves the app instance id from the service, or null if FirebaseAnalytics.ConsentType.ANALYTICS_STORAGE has been set to FirebaseAnalytics.ConsentStatus.DENIED.

我在日志中看到 ANALYTICS_STORAGE 被拒绝了。

Analytics storage consent denied; will not get app instance id

我不明白为什么拒绝提供 setConsent 方法声明默认授予所有类型

Sets the applicable end user consent state (e.g., for device identifiers) for this app on this device. Use the consent map to specify individual consent type values. Settings are persisted across app sessions. By default consent types are set to "granted".

我不确定我应该如何处理这个新的同意功能,但前提是有 public setter (setConsent) 我尝试手动设置granted 状态。 (Xamarin C# 代码,不是本机代码,但不应该相关)

_firebaseAnalytics.SetConsent(new Dictionary<ConsentType, ConsentStatus> 
{ 
  { ConsentType.AnalyticsStorage, ConsentStatus.Granted } 
});

没什么区别。

我应该如何处理这个新的同意功能才能获得应用程序实例 ID?

这是 Firebase 和 Google Play 参考的列表(同样,它是一个 Xamarin 应用程序,所以我有 Xamarin 参考,希望本地世界的翻译是显而易见的)

Manage consent settings 所述,Ads/Analytics 存储的默认值由应用程序 AndroidManifest.xml 文件中的 google_analytics_default_allow_ad_storagegoogle_analytics_default_allow_analytics_storage 决定。

因此,如果这些值设置为 true,那么这也会导致空值。

假设 none 适用,我看到 18.0.3“Fixed a bug in the Google Analytics Consent API”。所以也许这就是根本原因。

IOS注意事项:iOS14 为访问标识符 (IDFA) 添加了一个新的同意对话框,如果用户拒绝,无论有什么,它都将不可用开发商设置的。你可以 read more here.