FalconCode
FalconCode

Reputation: 11

AdColony SDK unavailable on current platform

I get an error when I try to use:

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

The error says:

AdColony SDK unavailable on current platform

this is how I'm trying to play the ad:

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);
    }
}

Upvotes: 1

Views: 563

Answers (1)

Programmer
Programmer

Reputation: 125435

Your current platform mode is likely one of the platforms the AdColony SDK don't support. AdColony SDK is supported on Android and iOS. Switch to Android or iOS from the Build Settings via the File ---> Build Settings menu or use code to to prevent on any platform that's not Android or iOS from calling Ads.Configure.

Do the check during run-time:

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

Or compile time:

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

Upvotes: 2

Related Questions