作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 Xamarin 中使用 C# 为 iOS 实现 RewardBasedVideoAd,但我似乎无法让它工作。这是我到目前为止所拥有的,它没有进入任何委托(delegate)功能。非常感谢任何帮助或建议。提前致谢。
public class AdMobImplementation : UIViewController,
IRewardBasedVideoAdDelegate
{
public AdMobImplementation()
{
RewardBasedVideoAd.SharedInstance.Delegate = this;
RewardBasedVideoAd.SharedInstance.LoadRequest(Request.GetDefaultRequest(), "ca-app-pub-3940256099942544/1712485313");
}
public void DidRewardUser(RewardBasedVideoAd rewardBasedVideoAd, AdReward reward)
{
Console.WriteLine("rewarded");
}
public void DidFailToLoad(RewardBasedVideoAd rewardBasedVideoAd, NSError error)
{
Console.WriteLine($"Reward based video ad failed to load with error: {error.LocalizedDescription}.");
}
public void DidReceiveAd(RewardBasedVideoAd rewardBasedVideoAd)
{
Console.WriteLine("Reward based video ad is received.");
}
public void DidOpen(RewardBasedVideoAd rewardBasedVideoAd)
{
Console.WriteLine("Opened reward based video ad.");
}
public void DidStartPlaying(RewardBasedVideoAd rewardBasedVideoAd)
{
Console.WriteLine("Reward based video ad started playing.");
}
public void DidClose(RewardBasedVideoAd rewardBasedVideoAd)
{
Console.WriteLine("Reward based video ad is closed.");
}
public void WillLeaveApplication(RewardBasedVideoAd rewardBasedVideoAd)
{
Console.WriteLine("Reward based video ad will leave application.");
}
}
最佳答案
问题终于解决了!您不需要处理 IRewardBasedVideoAdDelegate
。您所要做的就是从 RewardBasedVideoAdDelegate
继承您的类并覆盖所有必要的方法,例如:
public class AdMobImplementation : RewardBasedVideoAdDelegate
{
public AdMobImplementation()
{
RewardBasedVideoAd.SharedInstance.Delegate = this;
RewardBasedVideoAd.SharedInstance.LoadRequest(Request.GetDefaultRequest(), "ca-app-pub-3940256099942544/1712485313");
}
public override void DidRewardUser(RewardBasedVideoAd rewardBasedVideoAd, AdReward reward)
{
Console.WriteLine("rewarded");
}
public override void DidFailToLoad(RewardBasedVideoAd rewardBasedVideoAd, NSError error)
{
Console.WriteLine($"Reward based video ad failed to load with error:{error.LocalizedDescription}.");
}
public override void DidReceiveAd(RewardBasedVideoAd rewardBasedVideoAd)
{
Console.WriteLine("Reward based video ad is received.");
}
public override void DidOpen(RewardBasedVideoAd rewardBasedVideoAd)
{
Console.WriteLine("Opened reward based video ad.");
}
public override void DidStartPlaying(RewardBasedVideoAd rewardBasedVideoAd)
{
Console.WriteLine("Reward based video ad started playing.");
}
public override void DidClose(RewardBasedVideoAd rewardBasedVideoAd)
{
Console.WriteLine("Reward based video ad is closed.");
}
public override void WillLeaveApplication(RewardBasedVideoAd rewardBasedVideoAd)
{
Console.WriteLine("Reward based video ad will leave application.");
}
}
希望这对任何寻求解决方案的人有所帮助:)
关于c# - AdMob - iOS 实现 RewardBasedVideoAd,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53204429/
我正在尝试在 Xamarin 中使用 C# 为 iOS 实现 RewardBasedVideoAd,但我似乎无法让它工作。这是我到目前为止所拥有的,它没有进入任何委托(delegate)功能。非常感谢
我是一名优秀的程序员,十分优秀!