Hello! I have an Android game on Google Play and I am using Admob to show ads. Since Admob demands to show users GDPR Consent Message at the start of the game I am trying to implement it.
I created the message on Admob and managed to show it on Unity Editor with this script;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Ump.Api;
public class GDPRScript : MonoBehaviour
{
ConsentForm _consentForm;
void Start()
{
var debugSettings = new ConsentDebugSettings
{
// Geography appears as in EEA for debug devices.
DebugGeography = DebugGeography.EEA,
TestDeviceHashedIds = new List<string>
{
"I am using the advertising ID of my phone here."
}
};
// Here false means users are not under age.
ConsentRequestParameters request = new ConsentRequestParameters
{
TagForUnderAgeOfConsent = false,
ConsentDebugSettings = debugSettings,
};
// Check the current consent information status.
ConsentInformation.Update(request, OnConsentInfoUpdated);
}
void OnConsentInfoUpdated(FormError error)
{
if (error != null)
{
// Handle the error.
UnityEngine.Debug.LogError(error);
return;
}
if (ConsentInformation.IsConsentFormAvailable())
{
LoadConsentForm();
}
// If the error is null, the consent information state was updated.
// You are now ready to check if a form is available.
}
void LoadConsentForm()
{
// Loads a consent form.
ConsentForm.Load(OnLoadConsentForm);
}
void OnLoadConsentForm(ConsentForm consentForm, FormError error)
{
if (error != null)
{
// Handle the error.
UnityEngine.Debug.LogError(error);
return;
}
// The consent form was loaded.
// Save the consent form for future requests.
_consentForm = consentForm;
// You are now ready to show the form.
if (ConsentInformation.ConsentStatus == ConsentStatus.Required)
{
_consentForm.Show(OnShowForm);
}
}
void OnShowForm(FormError error)
{
if (error != null)
{
// Handle the error.
UnityEngine.Debug.LogError(error);
return;
}
// Handle dismissal by reloading form.
LoadConsentForm();
}
}
As I said the message works fine on the editor but doesn’t show up on the build. I checked with Logcat and didn’t see any errors.
What could be the problem here?