您现在的位置是:首页 >学无止境 >ios native 接入穿山甲sdk网站首页学无止境
ios native 接入穿山甲sdk
【记录】穿山甲广告iOS版SDK接入记录_ios 集成穿山甲_sanjieshenwu1987的博客-CSDN博客
1、pod导入外部文件;
2、appDelegate文件中
3、 代码文件
class AskViewController: UIViewController,BUNativeExpressRewardedVideoAdDelegate{
增加协议代理
4、广告加载
var rewardedVideoAd : BUNativeExpressRewardedVideoAd!
var isAdPlayed:Bool = false;
func loadAdAction()
{
var model = BURewardedVideoModel.init();
model.userId = "tag123";
self.rewardedVideoAd = BUNativeExpressRewardedVideoAd.init(slotID: "123232", rewardedVideoModel: model)
self.rewardedVideoAd.delegate = self;
self.rewardedVideoAd.loadData();
}
func showAdAction()
{
print("show ad action")
if (self.rewardedVideoAd != nil) {
print("show ad...")
self.rewardedVideoAd.show(fromRootViewController: self);
}else{
print("重新加载广告")
loadAdAction();
}
}
func nativeExpressRewardedVideoAd(_ rewardedVideoAd: BUNativeExpressRewardedVideoAd, didFailWithError error: Error?) {
print("广告加载失败")
print(error)
loadAdAction();
}
func nativeExpressRewardedVideoAdServerRewardDidSucceed(_ rewardedVideoAd: BUNativeExpressRewardedVideoAd, verify: Bool) {
print("广告播放成功")
//发放奖励
loadAdAction();
}