Claudio Redi
Claudio Redi

Reputation: 68400

Why is FirebaseAnalytics.ConsentType ANALYTICS_STORAGE denied by default?

I upgraded firebase analytics to v18.0.2 and after that, I cannot get anymore app instance id using getAppInstanceId, I started to get null.

According docs for getAppInstanceId

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

I see in my logs that ANALYTICS_STORAGE is denied.

Analytics storage consent denied; will not get app instance id

I don't understand why is denied provided setConsent method states that all types are granted by default

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".

I'm not sure how I'm supposed to deal with this new consent feature but provided there is a public setter (setConsent) I tried to manually set the granted status. (Xamarin C# code, not native but it shouldn't be relevant)

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

It didn't make a difference.

How should I deal with this new consent feature so I can get the app instance id?

This is the list of Firebase and Google Play references (Again, it's a Xamarin app so I have Xamarin references, hopefully the translation to native world is obvious)

enter image description here

Upvotes: 1

Views: 4644

Answers (1)

Kato
Kato

Reputation: 40582

As mentioned under Manage consent settings, the default values for Ads/Analytics storage are determined by google_analytics_default_allow_ad_storage and google_analytics_default_allow_analytics_storage in the app's AndroidManifest.xml file.

So if those values are set to true then this would also result in a null value.

Assuming none of this applies, I see that 18.0.3 "Fixed a bug in the Google Analytics Consent API". So maybe that's the root cause.

NOTE FOR IOS: iOS 14 added a new consent dialog for access to the identifier (IDFA) and if this is declined by the user, it will not be available no matter what has been set by the developer. You can read more here.

Upvotes: 1

Related Questions