Secondo le Norme relative al consenso degli utenti dell'UE di Google, è obbligatorio informare gli utenti nello Spazio economico europeo (SEE) e nel Regno Unito e ricevere il loro consenso per l'utilizzo dei cookie o di altro spazio di archiviazione locale, ove richiesto dalla legge, nonché per l'utilizzo dei dati personali (ad esempio l'ID pubblicità) per la pubblicazione degli annunci. Queste norme riflettono i requisiti della direttiva e-Privacy e del Regolamento generale sulla protezione dei dati (GDPR) dell'UE.
Per supportare i publisher nell'adempimento degli obblighi previsti da queste norme, Google offre l'SDK UMP (User Messaging Platform). L'SDK UMP è stato aggiornato per supportare i più recenti standard IAB. Tutte queste configurazioni ora possono essere gestite comodamente in AdMob privacy e messaggi.
Prerequisiti
- Completa la Guida introduttiva
- Se lavori sui requisiti relativi al GDPR, leggi In che modo i requisiti IAB influiscono sui messaggi per il consenso degli utenti dell'UE
Crea un tipo di messaggio
Crea messaggi per gli utenti con uno dei tipi di messaggi per gli utenti disponibili nella scheda Privacy e messaggi del tuo AdMob account. L'SDK UMP tenta di visualizzare un messaggio utente creato dall' AdMob ID applicazione impostato nel progetto. Se per la tua applicazione non è configurato alcun messaggio, l'SDK restituisce un errore.
Per maggiori dettagli, consulta Informazioni su privacy e messaggi.
Richiesta di informazioni relative al consenso
Devi richiedere un aggiornamento delle informazioni sul consenso dell'utente a ogni avvio dell'app, utilizzando Update()
. Questa opzione determina se l'utente deve dare il consenso se non l'ha già fatto o se il consenso è scaduto.
Ecco un esempio di come controllare lo stato all'avvio dell'app:
void Start()
{
// Set tag for under age of consent.
// Here false means users are not under age of consent.
ConsentRequestParameters request = new ConsentRequestParameters
{
TagForUnderAgeOfConsent = false,
};
// Check the current consent information status.
ConsentInformation.Update(request, OnConsentInfoUpdated);
}
void OnConsentInfoUpdated(FormError consentError)
{
if (consentError != null)
{
// Handle the error.
UnityEngine.Debug.LogError(consentError);
return;
}
// If the error is null, the consent information state was updated.
// You are now ready to check if a form is available.
}
Carica e mostra un modulo di consenso se necessario
Dopo aver ricevuto lo stato del consenso più aggiornato, chiamaLoadAndShowConsentFormIfRequired()
nella classeConsentForm
per caricare un modulo di consenso. Se lo stato del consenso è obbligatorio, l'SDK carica un modulo e lo presenta immediatamentefornito. Il Action<FormError>
callback
viene richiamato dopo che il modulo viene ignorato. Se non è richiesto il consenso, il Action<FormError>
callback
viene chiamato immediatamente.
void Start()
{
// Set tag for under age of consent.
// Here false means users are not under age of consent.
ConsentRequestParameters request = new ConsentRequestParameters
{
TagForUnderAgeOfConsent = false,
};
// Check the current consent information status.
ConsentInformation.Update(request, OnConsentInfoUpdated);
}
void OnConsentInfoUpdated(FormError consentError)
{
if (consentError != null)
{
// Handle the error.
UnityEngine.Debug.LogError(consentError);
return;
}
// If the error is null, the consent information state was updated.
// You are now ready to check if a form is available.
ConsentForm.LoadAndShowConsentFormIfRequired((FormError formError) =>
{
if (formError != null)
{
// Consent gathering failed.
UnityEngine.Debug.LogError(consentError);
return;
}
// Consent has been gathered.
});
}
Se devi eseguire azioni dopo che l'utente ha effettuato una scelta o ha ignorato il modulo, inserisci questa logica nel Action<FormError>
callbackmodulo.
Richiedi annunci
Prima di richiedere annunci nella tua app, controlla se hai ottenuto il consenso da parte dell'utente utilizzando . Ci sono due punti da controllare durante la raccolta del consenso:
- Una volta raccolto il consenso nella sessione corrente.
- Subito dopo aver chiamato
Update()
. È possibile che il consenso sia stato ottenuto nella sessione precedente. Come best practice per la latenza, ti consigliamo di non attendere il completamento del callback in modo da poter iniziare a caricare gli annunci il prima possibile dopo l'avvio dell'app.
Se si verifica un errore durante la procedura di raccolta del consenso, devi comunque provare a richiedere gli annunci. L'SDK UMP utilizza lo stato del consenso della sessione precedente.
void Start()
{
// Set tag for under age of consent.
// Here false means users are not under age of consent.
ConsentRequestParameters request = new ConsentRequestParameters
{
TagForUnderAgeOfConsent = false,
};
// Check the current consent information status.
ConsentInformation.Update(request, OnConsentInfoUpdated);
}
void OnConsentInfoUpdated(FormError consentError)
{
if (consentError != null)
{
// Handle the error.
UnityEngine.Debug.LogError(consentError);
return;
}
// If the error is null, the consent information state was updated.
// You are now ready to check if a form is available.
ConsentForm.LoadAndShowConsentFormIfRequired((FormError formError) =>
{
if (formError != null)
{
// Consent gathering failed.
UnityEngine.Debug.LogError(consentError);
return;
}
// Consent has been gathered.
if (ConsentInformation.CanRequestAds())
{
MobileAds.Initialize((InitializationStatus initstatus) =>
{
// TODO: Request an ad.
});
}
});
}
Test
Se vuoi testare l'integrazione nella tua app durante lo sviluppo, segui i passaggi riportati di seguito per registrare in modo programmatico il dispositivo di test.
- Chiama il numero
Update()
. Controlla se nell'output del log è presente un messaggio simile a quello riportato di seguito, che mostra l'ID dispositivo e come aggiungerlo come dispositivo di test:
Android
Use new ConsentDebugSettings.Builder().addTestDeviceHashedId("33BE2250B43518CCDA7DE426D04EE231") to set this as a debug device.
iOS
<UMP SDK>To enable debug mode for this device, set: UMPDebugSettings.testDeviceIdentifiers = @[2077ef9a63d2b398840261c8221a0c9b]
Copia l'ID dispositivo di test negli appunti.
Modifica il codice per chiamare
DebugGeography.TestDeviceHashedIds
e trasmettere un elenco di ID dispositivo di test.
void Start()
{
var debugSettings = new ConsentDebugSettings
{
DebugGeography = DebugGeography.TestDeviceHashedIds =
new List<string>
{
"TEST-DEVICE-HASHED-ID"
}
};
// Set tag for under age of consent.
// Here false means users are not under age of consent.
ConsentRequestParameters request = new ConsentRequestParameters
{
TagForUnderAgeOfConsent = false,
ConsentDebugSettings = debugSettings,
};
// Check the current consent information status.
ConsentInformation.Update(request, OnConsentInfoUpdated);
}
Forzare un'area geografica
L'SDK UMP consente di testare il comportamento della tua app come se il dispositivo si trovasse
nel SEE o nel Regno Unito utilizzando the DebugGeography
field on ConsentDebugSettings
. Tieni presente che le impostazioni di debug funzionano solo sui dispositivi di test.
void Start()
{
var debugSettings = new ConsentDebugSettings
{
// Geography appears as in EEA for debug devices.
DebugGeography = DebugGeography.EEA,
TestDeviceHashedIds = new List<string>
{
"TEST-DEVICE-HASHED-ID"
}
};
// Set tag for under age of consent.
// Here false means users are not under age of consent.
ConsentRequestParameters request = new ConsentRequestParameters
{
TagForUnderAgeOfConsent = false,
ConsentDebugSettings = debugSettings,
};
// Check the current consent information status.
ConsentInformation.Update(request, OnConsentInfoUpdated);
}
Reimposta stato del consenso
Durante il test della tua app con l'SDK UMP, potrebbe essere utile reimpostare lo stato dell'SDK in modo da simulare l'esperienza della prima installazione di un utente.
L'SDK offre Reset()
il metodo per farlo.
ConsentInformation.Reset();