【记录】穿山甲广告iOS版SDK接入记录

【记录】穿山甲广告iOS版SDK接入记录,第1张

官方接入文档
获取 framework 文件 (平台接入模块->SDK下载与接入文档),要先注册

其他参考
Creator iOS接入穿山甲SDK

1、集成SDK

这里采用pod

pod  Ads-CN 

AppDelegate.m

#import <BUAdSDK/BuAdSDK.h>
...
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
	...
	// 这个ID用的demo里的
	[BUAdSDKManager setAppID:@"5000546"];
    [BUAdSDKManager setLoglevel:BUAdSDKLogLevelDebug];
	...
}
2、开屏广告

在 -application: didFinishLaunchingWithOptions: 方法中调用

	- (void)addSplashAd
{
    self.splashAdView = [[BUSplashAdView alloc] initWithSlotID:@"800546808" frame:[UIScreen mainScreen].bounds];
    self.splashAdView.tolerateTimeout = 30;
    self.splashAdView.delegate = self;
    [self.splashAdView loadAdData];
    
    [self.window.rootViewController.view addSubview:self.splashAdView];
    self.splashAdView.rootViewController = self.window.rootViewController;
}

- (void)removeSplashAdView {
    if (self.splashAdView) {
        [self.splashAdView removeFromSuperview];
        self.splashAdView = nil;
    }
}

注意 : 参照demo处理代理方法
在splashAdDidClick、splashAdDidClickSkip、splashAd:didFailWithError、splashAdDidCloseOtherController: interactionType、splashAdCountdownToZero回调方法中进行广告的移除 *** 作,避免异常情况的发生: [self.splashView removeSplashView];

代理方法(BUSplashAdDelegate)

- (void)splashAdDidClick:(BUSplashAdView *)splashAd
{
    if (splashAd.zoomOutView) {
        [splashAd.zoomOutView removeFromSuperview];
    }
    [self removeSplashAdView];
}

- (void)splashAdDidClickSkip:(BUSplashAdView *)splashAd
{
    if (!splashAd.zoomOutView) {
        [self removeSplashAdView];
    }
}

- (void)splashAdDidClose:(BUSplashAdView *)splashAd
{
    [self removeSplashAdView];
}

- (void)splashAdDidCloseOtherController:(BUSplashAdView *)splashAd interactionType:(BUInteractionType)interactionType
{
    [self removeSplashAdView];
}
3、视频广告
- (void)loadAdAction
{
    BURewardedVideoModel *model = [[BURewardedVideoModel alloc] init];// 900546319 900546826
    self.rewardedVideoAd = [[BURewardedVideoAd alloc] initWithSlotID:@"900546319" rewardedVideoModel:model];
    self.rewardedVideoAd.delegate = self;
    [self.rewardedVideoAd loadAdData];
}

- (void)showAdAction
{
    if (self.rewardedVideoAd) {
        [self.rewardedVideoAd showAdFromRootViewController:self];
    }
}

代理(BURewardedVideoAdDelegate)

- (void)rewardedVideoAdDidLoad:(BURewardedVideoAd *)rewardedVideoAd {
    self.tipLabel.text = @"加载中...";
}

- (void)rewardedVideoAdVideoDidLoad:(BURewardedVideoAd *)rewardedVideoAd {
    self.tipLabel.text = @"视频加载完成";
}

- (void)rewardedVideoAd:(BURewardedVideoAd *)rewardedVideoAd didFailWithError:(NSError *)error {
    self.tipLabel.text = @"加载失败";
}

- (void)rewardedVideoAdDidClose:(BURewardedVideoAd *)rewardedVideoAd {
    _tipLabel.text = @"点击左边按钮加载广告。";
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/990686.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存