#import "InAppDisplayBannerViewController.h"
#import "AdViewDemoMacros.h"

NSString * const storedImpDisplayBannerInApp = @"POSIDjw2dypnd7yv8";

@interface InAppDisplayBannerViewController ()

// adview
@property (nonatomic) ADVIEW_BannerView * adviewBannerView;

@end

@implementation InAppDisplayBannerViewController

- (void)loadView {
    [super loadView];
    
    [self createAd];
}

- (void)createAd {
    // 1. Create a ADVIEW_BannerView
    self.adviewBannerView = [[ADVIEW_BannerView alloc] initWithFrame:CGRectMake(0, 0, self.adSize.width, self.adSize.height) configID:storedImpDisplayBannerInApp adSize:self.adSize];
    
    // 2. Configure the ADVIEW_BannerView
    self.adviewBannerView.delegate = self;
    self.adviewBannerView.adFormat = ADVIEW_AdFormat.banner;
    self.adviewBannerView.videoParameters.placement = ADVIEW_Placement.InBanner;
    
    // Add AdViewbanner view to the app UI
    [self.bannerView addSubview:self.adviewBannerView];
    
    // 3. Load the banner ad
    [self.adviewBannerView loadAd];
}

// MARK: - ADVIEW_BannerViewDelegate

- (UIViewController *)bannerViewPresentationController {
    return self;
}

- (void)bannerView:(ADVIEW_BannerView *)bannerView didFailToReceiveAdWith:(NSError *)error {
    AdViewDemoLogError(@"%@", error.localizedDescription);
}

@end
