Skip to content

1.1.2

Choose a tag to compare

@binouze binouze released this 16 Apr 09:27
· 12 commits to main since this release
  • Added method GetCanRequestAds if needed for GoogleAds implementation.
  • Added methods to help manage FirebaseAnalytics consent.

I implemented the methods GoogleUserMessagingPlatform .GetFirebaseAdStorage(), GoogleUserMessagingPlatform .GetFirebaseAdPersonalization() and GoogleUserMessagingPlatform .GetFirebaseAdUserData() from my understanding of the not very detailed documentation from Google https://developers.google.com/tag-platform/security/guides/implement-TCF-strings and some testings.

If interested here is an exemple of how to use it:

var FirebaseConsent = new Dictionary<ConsentType, ConsentStatus>();
if( GoogleUserMessagingPlatform.IsGDPRRequired() )
{
    var vendorAutorized = GoogleUserMessagingPlatform.GetConsentForVendor( VendorsIds.Google );
    if( vendorAutorized )
    {
        // GoogleVendor consent OK
        
        var adStorage  = GoogleUserMessagingPlatform.GetFirebaseAdStorage();
        var adPerso    = GoogleUserMessagingPlatform.GetFirebaseAdPersonalization();
        var adUserData = GoogleUserMessagingPlatform.GetFirebaseAdUserData();
        
        Debug.Log( $"Maj Firebase consent: adStorage:{adStorage} adPerso:{adPerso} adUserData:{adUserData}" );
    
        FirebaseConsent.Add( ConsentType.AnalyticsStorage,  adStorage  ? ConsentStatus.Granted : ConsentStatus.Denied );
        FirebaseConsent.Add( ConsentType.AdPersonalization, adPerso    ? ConsentStatus.Granted : ConsentStatus.Denied );
        FirebaseConsent.Add( ConsentType.AdStorage,         adStorage  ? ConsentStatus.Granted : ConsentStatus.Denied );
        FirebaseConsent.Add( ConsentType.AdUserData,        adUserData ? ConsentStatus.Granted : ConsentStatus.Denied );
    
        // or maybe true as vendor is consented
        FirebaseAnalytics.SetAnalyticsCollectionEnabled(adStorage || adPerso || adUserData); 
    }
    else
    {
        // GoogleVendor NOT CONSENTED

        Debug.Log( "Google vendor not consented" );
        
        FirebaseConsent.Add( ConsentType.AnalyticsStorage,  ConsentStatus.Denied );
        FirebaseConsent.Add( ConsentType.AdPersonalization, ConsentStatus.Denied );
        FirebaseConsent.Add( ConsentType.AdStorage,         ConsentStatus.Denied );
        FirebaseConsent.Add( ConsentType.AdUserData,        ConsentStatus.Denied );
    
        FirebaseAnalytics.SetAnalyticsCollectionEnabled(false); 
    }
}
else
{
    // GDPR NOT APPLICABLE
    
    FirebaseConsent.Add( ConsentType.AnalyticsStorage,  ConsentStatus.Granted );
    FirebaseConsent.Add( ConsentType.AdPersonalization, ConsentStatus.Granted );
    FirebaseConsent.Add( ConsentType.AdStorage,         ConsentStatus.Granted );
    FirebaseConsent.Add( ConsentType.AdUserData,        ConsentStatus.Granted );
    
    FirebaseAnalytics.SetAnalyticsCollectionEnabled(true); 
}

FirebaseAnalytics.SetConsent(FirebaseConsent);