Obsługa trybu zgody Google w wersji 2 dla pakietów SDK inApp
WAŻNE: Z wersji 3.3.0 włączyliśmy, wdrożyliśmy automatyczna aktualizacja statusu trybu zgody Firebase, poprzez introspekcjęNasz pakiet CMP SDK automatycznie wykrywa, czy Twoja aplikacja integruje się z Firebase, i automatycznie wywoła setConsent() metoda z Firebase do aktualizacji zgód poprzez introspekcję/refleksję, chyba że wyłączysz to zachowanie za pomocą Sposób setAutomaticConsentUpdatesEnabled(false)Sprawdź poniższe fragmenty kodu i wybierz strategię, która najlepiej pasuje do Twojego przypadku użycia. Upewnij się, że NIE zezwalasz naszemu zestawowi SDK na automatyczne ustawianie zgody, A TAKŻE nie wywołujesz metody setConsent() Firebase w swoim kodzie, ponieważ zduplikowane sygnały z pewnością doprowadzą do nieprzewidywalnych rezultatów.
Szukasz CMP obsługującego tryb zgody Google? Zobacz nasze Tryb zgody Google, wersja 2 strona produktu.
Ten przewodnik zawiera instrukcje dotyczące integracji trybu zgody Google z trybem niestandardowym ConsentManager w aplikacji na Androida 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ą obsługą Google Analytics.
- Pakiet SDK Firebase zintegrowany z Twoim projektem na iOS.
-
CMPManagerskonfigurowane w Twoim projekcie.
Omówienie
Od wersji 3.3.0 nasz mobilny pakiet SDK CMP domyślnie automatycznie sprawdza, czy Twoja aplikacja mobilna integruje się z Firebase, i wywołuje metodę setConsent() Firebase poprzez introspekcję/refleksję, aby ułatwić naszym klientom propagowanie zgód z 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ęczna propagacja iOS do Firebase
/// Synchronizes the consent status from CMP to Firebase Analytics
func syncConsentToFirebase() {
let consentMode = CMPManager.shared.getGoogleConsentModeStatus()
FirebaseConsentService.shared.updateFirebaseConsent(consentMode: consentMode)
}







