ios - Unity IronSource Ads iOS 初始化错误
问题描述
我正在尝试将 IronSource 广告集成到我的 Unity 项目中。当我构建我的应用程序,在 XCode 中打开它并在我的 iPhone 6s 上运行它进行测试时,我收到一条消息,告诉我 IronSource API 没有插页式广告。错误消息是:
“(日期)AdManager(<- 我的脚本名称)[ironSource SDK] API:IronSource:hasINterstitial false”
此外,插页式广告未初始化。所以“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");
}
推荐阅读
- javascript - 如何根据cropper js中的图像设置初始缩放幻灯片值
- java - spring boot api 启动失败
- vba - 分配变量以解决 VBA 中的行(Office 2019)
- python - 新用户在系统消息通道中加入服务器时如何发送消息?
- javascript - 使用 Lodash.remove 通过 Vuex 突变更改状态不会触发我的 Vue 组件中的反应式重新渲染
- maven - 嗨团队,我如何找到已经建立的现有项目的原型
- javascript - 它是如何通过 JS 进行隐式转换的原因是什么
- nopcommerce - 如何动态设置价格:nopcommerce
- java - 计数字符、Java 程序和 wc 产生不一致的结果
- node.js - Github 的操作不是构建 React 应用程序