插屏广告是app等待时,给用户显示的广告类型。
属性 | 说明 |
---|---|
adConfiguration | 广告配置对象 |
delegate | 广告代理声明 |
方法 | 说明 |
---|---|
initWithAdConfiguration: | 创建初始化对象adConfiguration 广告配置 |
loadInterstitialAd | 广告请求 |
showInterstitialAdWithRootViewController: | 显示插屏广告 |
removeInterstitialAd | 销毁插屏广告对象 |
方法 | 说明 |
---|---|
ampsInterstitialAdLoadSuccess: | 插屏广告加载成功 |
ampsInterstitialAdLoadFail: error: | 插屏广告加载失败 |
ampsInterstitialAdRenderSuccess: | 插屏广告渲染成功 |
ampsInterstitialAdRenderFail: error: | 插屏广告渲染失败 |
ampsInterstitialAdDidShow: | 插屏广告显示 |
ampsInterstitialAdShowFail: error: | 插屏广告显示失败 |
ampsInterstitialAdDidClick: | 插屏广告点击 |
ampsInterstitialAdDidClose: | 插屏广告关闭 |
广告加载与显示:
#import <AdScopeFoundation/AdScopeFoundation.h>
#import <AMPSAdSDK/AMPSAdSDK.h>
@interface AMPSADNInterstitialViewController () <AMPSInterstitialAdDelegate>
@property (nonatomic, strong) AMPSInterstitialAd *interstitialAd;
@property (nonatomic, strong) UILabel *resultsLabel;
@end
@implementation AMPSADNInterstitialViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
UIButton *requestBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[requestBtn setTitleColor:[UIColor adScopeColorWithHexString:@"#000000"] forState:UIControlStateNormal];
[requestBtn setTitle:@"请求广告" forState:UIControlStateNormal];
requestBtn.frame = CGRectMake(15, kAdScopeDemoNavHeight+15, self.view.frame.size.width-30, 40);
requestBtn.layer.masksToBounds = YES;
requestBtn.layer.borderWidth = 1;
requestBtn.layer.borderColor = [UIColor adScopeColorWithHexString:@"999999"].CGColor;
requestBtn.layer.cornerRadius = 3;
[requestBtn addTarget:self action:@selector(requestBtnClick) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:requestBtn];
UIButton *showBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[showBtn setTitleColor:[UIColor adScopeColorWithHexString:@"#000000"] forState:UIControlStateNormal];
[showBtn setTitle:@"显示广告" forState:UIControlStateNormal];
showBtn.frame = CGRectMake(requestBtn.adScopeFrameLeft, requestBtn.adScopeFrameBottom+15, requestBtn.adScopeFrameWidth, 40);
showBtn.layer.masksToBounds = YES;
showBtn.layer.borderWidth = 1;
showBtn.layer.borderColor = [UIColor adScopeColorWithHexString:@"999999"].CGColor;
showBtn.layer.cornerRadius = 3;
[showBtn addTarget:self action:@selector(showBtnClick) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:showBtn];
self.resultsLabel = [[UILabel alloc]initWithFrame:CGRectMake(showBtn.adScopeFrameLeft, showBtn.adScopeFrameBottom+15, showBtn.adScopeFrameWidth, 30)];
self.resultsLabel.textColor = [UIColor redColor];
self.resultsLabel.textAlignment = NSTextAlignmentCenter;
self.resultsLabel.text = @"广告请求日志";
[self.view addSubview:self.resultsLabel];
}
- (void)requestBtnClick {
AMPSAdConfiguration *cfg = [[AMPSAdConfiguration alloc]init];
cfg.spaceId = kAdScopeDemoADNSDKInterstitialID;
self.interstitialAd = [[AMPSInterstitialAd alloc]initWithAdConfiguration:cfg];
self.interstitialAd.delegate = self;
[self.interstitialAd loadInterstitialAd];
self.resultsLabel.text = @"请求中。。。";
}
- (void)showBtnClick {
[self.view endEditing:YES];
[self.interstitialAd showInterstitialAdWithRootViewController:self];
}
- (void)ampsInterstitialAdLoadSuccess:(AMPSInterstitialAd *)interstitialAd {
CookieADNLog(@"ampsInterstitialAdLoadSuccess");
}
- (void)ampsInterstitialAdLoadFail:(AMPSInterstitialAd *)interstitialAd error:(NSError *_Nullable)error {
self.resultsLabel.text = [NSString stringWithFormat:@"请求失败:%ld", error.code];
CookieADNLog(@"ampsInterstitialAdLoadFail:%@", error);
self.interstitialAd = nil;
}
- (void)ampsInterstitialAdRenderSuccess:(AMPSInterstitialAd *)interstitialAd {
self.resultsLabel.text = @"广告请求成功";
CookieADNLog(@"ampsInterstitialAdRenderSuccess");
}
- (void)ampsInterstitialAdRenderFail:(AMPSInterstitialAd *)interstitialAd error:(NSError *_Nullable)error {
self.resultsLabel.text = [NSString stringWithFormat:@"渲染失败:%ld", error.code];
CookieADNLog(@"ampsInterstitialAdRenderFail:%@", error);
self.interstitialAd = nil;
}
- (void)ampsInterstitialAdShowFail:(AMPSInterstitialAd *)interstitialAd error:(NSError *_Nullable)error {
self.resultsLabel.text = [NSString stringWithFormat:@"显示失败:%ld", error.code];
CookieADNLog(@"ampsInterstitialAdShowFail:%@", error);
self.interstitialAd = nil;
}
- (void)ampsInterstitialAdDidShow:(AMPSInterstitialAd *)interstitialAd {
CookieADNLog(@"ampsInterstitialAdDidShow");
}
- (void)ampsInterstitialAdDidClick:(AMPSInterstitialAd *)interstitialAd {
CookieADNLog(@"ampsInterstitialAdDidClick");
}
- (void)ampsInterstitialAdDidClose:(AMPSInterstitialAd *)interstitialAd {
self.resultsLabel.text = @"广告已关闭";
CookieADNLog(@"ampsInterstitialAdDidClose");
}
@end
/**
本次广告价格,单位分
*/
- (NSInteger)eCPM;
/**
@pararm winInfo 竞胜信息,字典类型
AMPS_WIN_PRICE :竞胜价格 (单位: 分),必填
AMPS_WIN_ADNID :竞胜渠道ID,必填
AMPS_HIGHRST_LOSS_PRICE :失败渠道中最高价格,必填
AMPS_EXPECT_PRICE :期望价格,选填
*/
- (void)sendWinNotificationWithInfo:(NSDictionary *)winInfo;
/**
@pararm lossInfo 竞败信息,字典类型
AMPS_WIN_PRICE :竞胜价格 (单位: 分),必填
AMPS_WIN_ADNID :竞胜渠道ID,必填
AMPS_HIGHRST_LOSS_PRICE :失败渠道中最高价格,必填
AMPS_LOSS_REASON :失败原因,必填
AMPS_EXPECT_PRICE :期望价格,选填
*/
- (void)sendLossNotificationWithInfo:(NSDictionary *)lossInfo;
类型相关的枚举请参考:AMPSAdSDKDefines