Info
Content

Google Consent Mode v2 Support for inApp SDKs

IMPORTANT: From version 3.3.0 on, we implemented the automatic update of Firebase Consent Mode Status, via introspection. Our CMP SDK automatically detects whether you app is integrating Firebase, and will automatically invoke the setConsent() method from Firebase to update the consents via introspection/reflection, unless you disable this behaviour using the method setAutomaticConsentUpdatesEnabled(false). Check the code chunks below and choose the strategy that best fits your use case. Make sure you DO NOT allow our SDK to automatically set the consent AND ALSO invoke Firebase's setConsent() method in your code, as the duplicate signals will for sure cause unpredictable results. 

Looking for a CMP that supports Google Consent Mode? See our Google Consent Mode v2 product page.

This guide provides instructions on how to integrate Google Consent Mode with the custom ConsentManager in your Android or iOS application.

Prerequisites

  • Ensure Consent Mode is enabled (Menu > CMPs > Integrations > Google Consent Mode)
  • Ensure Google Analytics, Google Ads or the other Google services are in your vendorlist
  • A Firebase project with Google Analytics enabled.
  • Firebase SDK integrated into your iOS project.
  • CMPManager set up in your project.

Overview

As a default behaviour, from v3.3.0 on our CMP mobile SDK will automatically check if your mobile app is integrating Firebase, and will invoke Firebase's setConsent() method via introspection/reflection in order to make it easier for our clients to make propagate the consents from your CMP to Firebase. Check the code below, and make sure you 

analytics = Firebase.analytics

val urlConfig = UrlConfig(
	id = "YOUR_CODE_ID",
	domain = "delivery.consentmanager.net",
	language = "EN",
	appName = "YourAppName"
)

cmpManager = CMPManager.getInstance(
    context = this,
    urlConfig = urlConfig,
    webViewConfig = webViewConfig,
    delegate = this
)

// IMPORTANT: This line below disables automatic propagation of GCM consent to Firebase
//            The default is TRUE, so if you suppress the line below, automatic
//            propagation WILL happen. If set to false like below, you'll need to MANUALLY invoke
//			  Firebase's setConsent() method, like demonstrated below.
cmpManager.setAutomaticConsentUpdatesEnabled(enabled = false)

cmpManager.setActivity(this)

cmpManager.checkAndOpen(false) { result ->
    result.onSuccess {
        navigateToHomeScreen()
    }.onFailure { error ->
        Log.e("DemoApp", "Check and open consent layer failed with error: $error")
    }

// Manual propagation of the consents to Firebase. You DO NOT need to do this
// if you .setAutomaticConsentUpdatesEnabled(true)
val firebaseConsent = cmpManager.getGoogleConsentModeStatus()    
firebaseAnalytics.setConsent(firebaseConsent)

iOS Manual propagation to Firebase

/// Synchronizes the consent status from CMP to Firebase Analytics
func syncConsentToFirebase() {
	let consentMode = CMPManager.shared.getGoogleConsentModeStatus()
	FirebaseConsentService.shared.updateFirebaseConsent(consentMode: consentMode)
}

 

Back to top