- Home /
Using AdMob with the Designed for Families programme
Hello,
i have integrated AdMob in my game, now i'm trying to make ads compliant with Google Designed for Families programme. What i've found is that AdMob offers tools to show compliant ads, as it is explained here:
https://support.google.com/admob/answer/6223431?hl=en-GB
Now the problem is that they mention a method that i can't find: addNetworkExtrasBundle. This is the code shown in their example:
Bundle extras = new Bundle();
extras.putBoolean("is_designed_for_families", true);
AdRequest request = new AdRequest.Builder()
.addNetworkExtrasBundle(AdMobAdapter.class, extras)
.tagForChildDirectedTreatment(true)
.build();
That method is not defined anywhere, and I can't find Bundle class either. I also tried something like this (the only choice to add extras):
AdRequest request = new AdRequest.Builder().TagForChildDirectedTreatment(true).AddExtra("is_designed_for_families", "true").Build();
but the app doesn't show any ad with this code. Anyway ads worked properly when i simply used AdRequest.Builder().Build(), but this doesn't give any control on ads content.
I know i can configure ads in AdMob units from their website, but I'm afraid I could make some mistake about selecting proper ads categories to be shown. I would prefer to use a safe tool like the one mentioned in google support.
I'm using AdMob plugin version 2.3.1. Anyway i've tried to download version 3.0.2 also, but i still can't find that method to add network extras.
I've searched everywhere but i can't find a solution; i've read something about mediation, but i think it is useless as i'm not using any other ad network apart of AdMob.
Please help me, any suggestion would be very appreciated. Thanks in advance.
Answer by kob_2015 · Mar 18, 2016 at 09:55 AM
Hi @ ZuPe2112 ,
You need to update the admob's plugin. You must replace the code below in the class Utils.cs:
foreach (KeyValuePair<string, string> entry in request.Extras)
{
bundle.Call("putString", entry.Key, entry.Value);
}
by
foreach (KeyValuePair<string, string> entry in request.Extras)
{ if (entry.Key == "is_designed_for_families")
{
if (entry.Value== "true")
bundle.Call("putBoolean", entry.Key, true);
else
bundle.Call("putBoolean", entry.Key, false);
}
else
{
bundle.Call("putString", entry.Key, entry.Value);
}
}
Hello @kob_2015,
thanks for your help, but this doesn't seem to work. I replaced the code as you explained and then i used this to instantiate the request object:
AdRequest request = new AdRequest.Builder()
.TagForChildDirectedTreatment(true)
.AddExtra("is_designed_for_families", "true")
.Build();