I'm creating a Unity game that uses admob mediation to show rewarded ads. I'm using about 5-10 different ad networks.
How do I implement GDPR compliance for EU users?
I tried following some online tutorials, but none of them had content showing getting GDPR consent for multiple networks.
How can I modify this script to correctly get compliance where needed for all of my ad networks?
public class Mediation : MonoBehaviour
{
string Video_Ad_Id = "ca-app-pub-3940256099942544/5224354917";
private RewardedAd rewardedAd;
public Button reviveBtn;
void Start()
{
MobileAds.Initialize((initStatus) =>
{
Dictionary<string, AdapterStatus> map = initStatus.getAdapterStatusMap();
foreach (KeyValuePair<string, AdapterStatus> keyValuePair in map)
{
string className = keyValuePair.Key;
AdapterStatus status = keyValuePair.Value;
switch (status.InitializationState)
{
case AdapterState.NotReady:
// The adapter initialization did not complete.
MonoBehaviour.print("Adapter: " + className + " not ready.");
break;
case AdapterState.Ready:
// The adapter was successfully initialized.
MonoBehaviour.print("Adapter: " + className + " is initialized.");
break;
}
}
});
RequestRewardBasedVideo();
}
void Update()
{
if (rewardedAd.IsLoaded())
{
reviveBtn.interactable = true;
}
}
I'm not sure where to ask for consent as I'm using multiple ad networks and not just admob. In the documentation, there is this line of code:
AdRequest request = new AdRequest.Builder().AddExtra("npa", "1") .Build();
Where do I add this in the script above and how do I ask for consent for multiple networks, like Chartboost, Adcolony, ironSource etc?
EDIT
I have added the following code to the mainmenu script which loads up when the game starts.
public GameObject GDPR_Popup;
void Start()
{
Invoke("CheckForGDPR",.25f);
}
void CheckForGDPR()
{
if (PlayerPrefs.GetInt("npa", -1) == -1)
{
GDPR_Popup.SetActive(true);
}
}
public void OnUserClickAccept()
{
PlayerPrefs.SetInt("npa", 0); //this is for google admob
AdColonyAppOptions.SetGDPRConsentString("1");
AppLovin.SetHasUserConsent(true);
GDPR_Popup.SetActive(false);
}
public void OnUserClickCancel()
{
PlayerPrefs.SetInt("npa", 1);//this is for google admob
AdColonyAppOptions.SetGDPRConsentString("0");
AppLovin.SetHasUserConsent(false);
GDPR_Popup.SetActive(false);
}
Would something like this work as I'm not sure how to test this?
Also, how to initialize the ad networks only when the user has accepted or canceled GDPR option(this I believe was mentioned in the google admob mediation documents but there was no code sample given).
Can someone please help?