AdColony SDK 在当前平台上不可用



尝试使用时出现错误:

Ads.Configure(this.AppID, appOptions, this.zoneIDs);

错误说:

AdColony SDK 在当前平台上不可用

这就是我尝试播放广告的方式:

public string AppID = "app53f882d220464f3399";
public string[] zoneIDs = new string[] { "vz53cbba96e85e4170b4", "vz53cbba96e85e4170b4" };
public void WatchADs()
{
ConfigureAds();
RegisterForAdsCallbacks();
//  RegisterForAdsCallbacksReward();
RequestAd();
PlayAd();
//RestartLevel();
}
void ConfigureAds()
{
// AppOptions are optional
AdColony.AppOptions appOptions = new AdColony.AppOptions();
appOptions.UserId = "JackAlope";
appOptions.TestModeEnabled = true;
appOptions.AdOrientation = AdColony.AdOrientationType.AdColonyOrientationAll;
if (Application.platform == RuntimePlatform.Android ||
Application.platform == RuntimePlatform.IPhonePlayer)
{
Ads.Configure(this.AppID, appOptions, this.zoneIDs);
}
}
void RegisterForAdsCallbacks()
{
AdColony.Ads.OnRequestInterstitial += (AdColony.InterstitialAd ad) => {
_ad = ad;
};
AdColony.Ads.OnExpiring += (AdColony.InterstitialAd ad) => {
AdColony.Ads.RequestInterstitialAd(ad.ZoneId, null);
};
}
void RequestAd()
{
AdColony.AdOptions adOptions = new AdColony.AdOptions();
adOptions.ShowPrePopup = true;
adOptions.ShowPostPopup = true;
if (Application.platform == RuntimePlatform.Android ||
Application.platform == RuntimePlatform.IPhonePlayer)
{
AdColony.Ads.RequestInterstitialAd(zoneIDs[0], adOptions);
}
}
void PlayAd()
{
if (_ad != null)
{
AdColony.Ads.ShowAd(_ad);
}
}

您当前的平台模式可能是 AdColony SDK 不支持的平台之一。AdColony SDK在Android和iOS上受支持。通过"文件--->构建设置"菜单从"构建设置"切换到 Android 或 iOS,或使用代码来防止在任何非 Android 或 iOS 的平台上调用Ads.Configure

在运行时执行检查:

if (Application.platform == RuntimePlatform.Android ||
Application.platform == RuntimePlatform.IPhonePlayer)
{
Ads.Configure(this.AppID, appOptions, this.zoneIDs);
}

或编译时:

#if UNITY_ANDROID || UNITY_IOS  
Ads.Configure(this.AppID, appOptions, this.zoneIDs);
#endif

相关内容

  • 没有找到相关文章

最新更新