Tryb zgody Google v2 Obsługa SDK w aplikacji

WAŻNE: Od wersji 3.3.0 wdrożyliśmy automatyczną aktualizację statusu trybu zgody Firebase poprzez introspekcję. Nasz CMP SDK automatycznie wykrywa, czy Twoja aplikacja integruje Firebase, i automatycznie wywoła metodę „setConsent()” z Firebase w celu aktualizacji zgód poprzez introspekcję/refleksję, chyba że wyłączysz to zachowanie za pomocą metody „setAutomaticConsentUpdatesEnabled(false)”. Sprawdź poniższe fragmenty kodu i wybierz strategię, która najlepiej pasuje do Twojego przypadku użycia. Upewnij się, że NIE pozwalasz naszemu SDK na automatyczne ustawianie zgody ORAZ wywoływanie metody setConsent() Firebase w swoim kodzie, ponieważ zduplikowane sygnały z pewnością spowodują nieprzewidywalne rezultaty. 

Szukasz platformy CMP obsługującej tryb zgody Google? Zapoznaj się z naszą stroną produktu Google Consent Mode v2.

Ten przewodnik zawiera instrukcje dotyczące integracji trybu zgody Google z niestandardowym modułem ConsentManager w aplikacji na system Android lub iOS.

Wymagania wstępne

  • Upewnij się, że tryb zgody jest włączony (Menu > CMP > Integracje > Tryb zgody Google)
  • Upewnij się, że Google Analytics, Google Ads lub inne usługi Google znajdują się na Twojej liście dostawców
  • Projekt Firebase z włączoną usługą Google Analytics.
  • Firebase SDK zintegrowane z Twoim projektem na iOS.
  • CMPManager skonfigurowane w Twoim projekcie.

Przegląd

Domyślnie, od wersji 3.3.0 nasze mobilne SDK CMP automatycznie sprawdza, czy Twoja aplikacja mobilna integruje Firebase, i wywołuje metodę setConsent() Firebase poprzez introspekcję/refleksję, aby ułatwić naszym klientom przekazywanie zgód z Twojego CMP do Firebase. Sprawdź poniższy kod i upewnij się, że 

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)

Ręczne przesyłanie danych z iOS do Firebase

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

 

We do our best to keep this purely informative documentation up to date. However, if you notice that any of these guides need a little touch-up, let us know!