#import <AdScopeFoundation/AdScopeFoundation.h>
#import <AMPSAdSDK/AMPSAdSDK.h>
@interface AMPSADNNormalNativeExpressViewController () <AMPSNativeExpressManagerDelegate, AMPSNativeExpressViewDelegate>
@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) AMPSNativeExpressManager *nativeExpressManager;
@property (nonatomic, strong) AMPSNativeExpressView *adView;
@end
@implementation AMPSADNNormalNativeExpressViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.scrollView];
[self setScrollViewAutoLayout];
AMPSAdConfiguration *cfg = [[AMPSAdConfiguration alloc]init];
cfg.spaceId = kAdScopeDemoADNSDKNativeID;
cfg.adSize = CGSizeMake(self.view.frame.size.width, 0);
self.nativeExpressManager = [[AMPSNativeExpressManager alloc]initWithAdConfiguration:cfg];
self.nativeExpressManager.delegate = self;
[self.nativeExpressManager loadNativeExpressManager];
}
- (void)ampsNativeAdLoadSuccess:(AMPSNativeExpressManager *)nativeAd {
CookieADNLog(@"AMPS-NativeExpress-LoadSuccess");
for (int i = 0; i < nativeAd.viewsArray.count; i++) {
AMPSNativeExpressView *adView = [nativeAd.viewsArray adScopeSafeObjectAtIndex:i];
adView.delegate = self;
adView.viewController = self;
adView.backgroundColor = [UIColor orangeColor];
[adView renderAd];
}
}
- (void)ampsNativeAdRenderSuccess:(AMPSNativeExpressView *)nativeView {
CookieADNLog(@"AMPS-NativeView-RenderSuccess");
[self.scrollView addSubview:nativeView];
}
- (void)ampsNativeAdRenderFail:(AMPSNativeExpressView *)nativeView error:(NSError *_Nullable)error {
CookieADNLog(@"AMPS-NativeExpress-LoadFail:%@", error);
}
- (void)ampsNativeAdExposured:(AMPSNativeExpressView *)nativeView {
CookieADNLog(@"AMPS-NativeView-Exposured");
}
- (void)ampsNativeAdDidClick:(AMPSNativeExpressView *)nativeView {
CookieADNLog(@"AMPS-NativeView-DidClick");
}
- (void)ampsNativeAdDidClose:(AMPSNativeExpressView *)nativeView {
CookieADNLog(@"AMPS-NativeView-DidClose");
}
#pragma mark 页面视图
- (UIScrollView *)scrollView {
if (!_scrollView) {
_scrollView = [[UIScrollView alloc]init];
_scrollView.backgroundColor = [UIColor whiteColor];
_scrollView.scrollEnabled = YES;
_scrollView.contentSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height-kAdScopeDemoNavHeight-30);
_scrollView.translatesAutoresizingMaskIntoConstraints = NO;
}
return _scrollView;
}
- (void)setScrollViewAutoLayout {
NSDictionary *views = @{@"scrollView":self.scrollView};
NSArray *hConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[scrollView]-0-|" options:NSLayoutFormatAlignAllCenterY metrics:nil views:views];
[self.view addConstraints:hConstraints];
NSArray *vConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[scrollView]-0-|" options:NSLayoutFormatAlignAllCenterX metrics:nil views:views];
[self.view addConstraints:vConstraints];
}
@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;