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 altri tipi di archiviazione locale, laddove richiesto dalla legge, e per l'utilizzo dei dati personali (ad esempio l'ID pubblicità) per la pubblicazione di 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 comodamente gestite in AdMob privacy e messaggi.
Prerequisiti
- Completa la Guida introduttiva
- Se lavori ai requisiti relativi al GDPR, leggi In che modo i requisiti IAB influiscono sui messaggi per il consenso dell'UE
Crea un tipo di messaggio
Crea i 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 non è configurato alcun messaggio per la tua applicazione, l'SDK restituisce un errore.
Per maggiori dettagli, consulta Informazioni su privacy e messaggi.
Richiesta di informazioni sul consenso
Devi richiedere un aggiornamento delle informazioni sul consenso dell'utente a ogni lancio dell'app, utilizzando Update()
. Questo determina se l'utente deve dare il consenso nel caso in cui non l'abbia 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
Importante: le API seguenti sono compatibili con l'SDK UMP versione 2.1.0 o successive.Dopo aver ricevuto lo stato del consenso più aggiornato, chiama
LoadAndShowConsentFormIfRequired()
il
ConsentForm
corso per caricare un modulo di consenso. Se lo
stato del consenso è obbligatorio, l'SDK carica un modulo e lo presenta immediatamente
specificato. Il Action<FormError>
callback
viene richiamato dopo che il modulo viene ignorato. Se il consenso non è richiesto, 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 scelto o ignorato il modulo, inserisci la logica corrispondente nel Action<FormError>
callbackmodulo.
Richiedi annunci
Prima di richiedere annunci nella tua app, verifica di aver ottenuto il consenso da parte dell'utente utilizzando . Esistono due punti da controllare durante la raccolta del consenso:
- Una volta ottenuto il consenso nella sessione corrente.
- Subito dopo aver chiamato
Update()
. È possibile che il consenso sia stato ottenuto nella sessione precedente. Come best practice in materia di 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.
});
}
});
}
Opzioni relative alla privacy
Alcuni moduli di consenso richiedono all'utente di modificare il consenso in qualsiasi momento. Rispetta i seguenti passaggi per implementare un pulsante Opzioni di privacy, se necessario.
A questo scopo:
- Implementa un elemento UI, ad esempio un pulsante nella pagina delle impostazioni dell'app, che può attivare un modulo delle opzioni di privacy.
- Una volta
LoadAndShowConsentFormIfRequired()
completato, controllaPrivacyOptionsRequirementStatus
per determinare se visualizzare l'elemento UI che può presentare il modulo delle opzioni di privacy. - Quando un utente interagisce con il tuo elemento UI, chiama
ShowPrivacyOptionsForm()
per mostrare il modulo in modo che l'utente possa aggiornare le opzioni sulla privacy in qualsiasi momento.
L'esempio seguente mostra come mostrare il modulo delle opzioni di privacy da un
Button
.
[SerializeField, Tooltip("Button to show the privacy options form.")]
private Button _privacyButton;
private void Start()
{
// Enable the privacy settings button.
if (_privacyButton != null)
{
_privacyButton.onClick.AddListener(UpdatePrivacyButton);
// Disable the privacy settings button by default.
_privacyButton.interactable = false;
}
}
/// <summary>
/// Shows the privacy options form to the user.
/// </summary>
public void ShowPrivacyOptionsForm()
{
Debug.Log("Showing privacy options form.");
ConsentForm.ShowPrivacyOptionsForm((FormError showError) =>
{
if (showError != null)
{
Debug.LogError("Error showing privacy options form with error: " + showError.Message);
}
// Enable the privacy settings button.
if (_privacyButton != null)
{
_privacyButton.interactable =
ConsentInformation.PrivacyOptionsRequirementStatus ==
PrivacyOptionsRequirementStatus.Required;
}
});
}
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 del tuo 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 dei tuoi ID dispositivo di test.
void Start()
{
var debugSettings = new ConsentDebugSettings
{
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 ti 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 la prima installazione di un utente.
L'SDK fornisce il Reset()
metodo per farlo.
ConsentInformation.Reset();