unity Admob——AdRequest的正确方式
Unity Admob - AdRequest the right way
我更改了演示脚本,它对我有用:
using GoogleMobileAds.Api;
…
void Start(){
RequestInterstitial();
}
private void RequestInterstitial()
{
#if UNITY_EDITOR
string adUnitId = "unused";
#elif UNITY_ANDROID
string adUnitId = "ca-app-pub-xxxxxxxxxxxxxxxxxxx";
#elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE
string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE";
#else
string adUnitId = "unexpected_platform";
#endif
// Create an interstitial.
interstitial = new InterstitialAd(adUnitId);
// Load an interstitial ad.
interstitial.LoadAd(createAdRequest());
}
private AdRequest createAdRequest()
{
return new AdRequest.Builder()
.AddTestDevice(AdRequest.TestDeviceSimulator)
.AddTestDevice("0123456789ABCDEF0123456789ABCDEF")
.AddKeyword("game")
.SetGender(Gender.Male)
.SetBirthday(new DateTime(1985, 1, 1))
.TagForChildDirectedTreatment(false)
.AddExtra("color_bg", "9B30FF")
.Build();
}
public void endGame(){
if (interstitial.IsLoaded())
{
interstitial.Show();
}
}
现在我想删除测试设备以在实际工作中使用它,我需要做的就是像这样更改方法 createAdRequest():
private AdRequest createAdRequest()
{
return new AdRequest.Builder().Build();
}
那行得通吗?我需要对 AdRequest 提出一些论点吗?如果我需要更改某些内容,有人可以举个例子吗?
谢谢
That will work?
是的。当然,您可以添加 SetGender
、SetBirthday
和其他选项,但它应该有效。准备好部署后,只需删除您已经在问题中完成的 AddTestDevice()
选项。
无论如何,我没有看到您订阅 OnAdRewarded
活动。当广告结束展示时调用此函数。你可以看到如何做到这一点 .
我更改了演示脚本,它对我有用:
using GoogleMobileAds.Api;
…
void Start(){
RequestInterstitial();
}
private void RequestInterstitial()
{
#if UNITY_EDITOR
string adUnitId = "unused";
#elif UNITY_ANDROID
string adUnitId = "ca-app-pub-xxxxxxxxxxxxxxxxxxx";
#elif (UNITY_5 && UNITY_IOS) || UNITY_IPHONE
string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE";
#else
string adUnitId = "unexpected_platform";
#endif
// Create an interstitial.
interstitial = new InterstitialAd(adUnitId);
// Load an interstitial ad.
interstitial.LoadAd(createAdRequest());
}
private AdRequest createAdRequest()
{
return new AdRequest.Builder()
.AddTestDevice(AdRequest.TestDeviceSimulator)
.AddTestDevice("0123456789ABCDEF0123456789ABCDEF")
.AddKeyword("game")
.SetGender(Gender.Male)
.SetBirthday(new DateTime(1985, 1, 1))
.TagForChildDirectedTreatment(false)
.AddExtra("color_bg", "9B30FF")
.Build();
}
public void endGame(){
if (interstitial.IsLoaded())
{
interstitial.Show();
}
}
现在我想删除测试设备以在实际工作中使用它,我需要做的就是像这样更改方法 createAdRequest():
private AdRequest createAdRequest()
{
return new AdRequest.Builder().Build();
}
那行得通吗?我需要对 AdRequest 提出一些论点吗?如果我需要更改某些内容,有人可以举个例子吗?
谢谢
That will work?
是的。当然,您可以添加 SetGender
、SetBirthday
和其他选项,但它应该有效。准备好部署后,只需删除您已经在问题中完成的 AddTestDevice()
选项。
无论如何,我没有看到您订阅 OnAdRewarded
活动。当广告结束展示时调用此函数。你可以看到如何做到这一点