微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Unity IronSource Ads iOS 初始化错误

如何解决Unity IronSource Ads iOS 初始化错误

我正在尝试将 ironsource 广告集成到我的 Unity 项目中。当我构建我的应用程序,在 XCode 中打开它并在我的 iPhone 6s 上运行它进行测试时,我收到一条消息,告诉我 ironsource API 没有间隙。 错误信息是:
"(DATE) AdManager(
此外,插页式广告不会初始化。所以“ironsource.Agent.isInterstitialReady()”保持错误。 我究竟做错了什么? 我已经导入了 SDK 并编写了这个脚本 (C#):

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AdManager : MonoBehavIoUr
{
private string AppKey = "MY_APP_ID";
void Start()
{
    Invoke("InitInterstitial",4);
}

#region interstitial
private void InitInterstitial()
{
    ironsource.Agent.init(AppKey,ironsourceAdUnits.INTERSTITIAL);
    while (!ironsource.Agent.isInterstitialReady()) { Debug.Log("Initializing..."); }
    Debug.Log("Initialized!");
    ironsource.Agent.loadInterstitial();
    Debug.Log("Loaded!");
}

void OnEnable()
{
    ironsourceEvents.onInterstitialAdReadyEvent += InterstitialAdReadyEvent;
    ironsourceEvents.onInterstitialAdLoadFailedEvent += InterstitialAdLoadFailedEvent;
    ironsourceEvents.onInterstitialAdShowSucceededEvent += InterstitialAdShowSucceededEvent;
    ironsourceEvents.onInterstitialAdShowFailedEvent += InterstitialAdShowFailedEvent;
    ironsourceEvents.onInterstitialAdClickedEvent += InterstitialAdClickedEvent;
    ironsourceEvents.onInterstitialAdOpenedEvent += InterstitialAdOpenedEvent;
    ironsourceEvents.onInterstitialAdClosedEvent += InterstitialAdClosedEvent;
}

//Invoked when the initialization process has Failed.
//@param description - string - contains information about the failure.
void InterstitialAdLoadFailedEvent(ironsourceError error)
{
    Debug.LogError("ERROR!!__: " + error);
}
//Invoked right before the Interstitial screen is about to open.
void InterstitialAdShowSucceededEvent()
{
}
//Invoked when the ad fails to show.
//@param description - string - contains information about the failure.
void InterstitialAdShowFailedEvent(ironsourceError error)
{
}
// Invoked when end user clicked on the interstitial ad
void InterstitialAdClickedEvent()
{
}
//Invoked when the interstitial ad closed and the user goes back to the application screen.
void InterstitialAdClosedEvent()
{
}
//Invoked when the Interstitial is Ready to shown after load function is called
void InterstitialAdReadyEvent()
{
    Debug.Log("_______READY!_____");
}
//Invoked when the Interstitial Ad Unit has opened
void InterstitialAdOpenedEvent()
{
}

public void ShowInterstitial()
{
    ironsource.Agent.showInterstitial();
}

#endregion

}

(Debug.Logs 仅用于调试我的问题) 感谢您的帮助!

解决方法

看起来 while 循环永远不会结束。 实际触发广告请求的函数是:

IronSource.Agent.loadInterstitial();

尝试执行以下操作:

private void InitInterstitial()
{
    IronSource.Agent.init(AppKey,IronSourceAdUnits.INTERSTITIAL);
    Debug.Log("Initializing..."); }    
    IronSource.Agent.loadInterstitial();
}

//Invoked when the Interstitial is Ready to shown after load function is called
void InterstitialAdReadyEvent()
{
    Debug.Log("Ad Loaded");
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。