Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Traditional Formats

Traditional formats are generally rectangular and they are inserted into the app’s content. To show this type of ads, you must create and instantiate a “BannerAdView”.

Before creating a “BannerAdView”, it is necessary to import certain controls, as it is shown in the sample code. Then, the “BannerAdView” is created inside an iframe, indicating the placement ID and the selected size.

For your reference, please read the following chart of suggested sizes:

 

Non-retina Smartphones

300x50 / 320x50

Retina/High Resolution Smartphones

640x100

Tablets

728x90 / 300x250

 

The next example shows how to implement a 300x50 ad in an iOS Application activity.

Note that in the parameter placementId: the placement should indicate what`s needed to display. This example includes '186f6651be1753f8'.

 

#import 'FunViewController.h'
#import 'ANBannerAdView.h'
 
@interface FunViewController ()
 
@end
 
@implementation FunViewController
 
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    // Get the screen size so we can center our 300x50 example ad
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    CGFloat centerX = (screenRect.size.width / 2) - 150;
    CGFloat centerY = (screenRect.size.height / 2) - 25;
    
    // Set up some sizing variables we'll need when we create our ad view
    CGRect rect = CGRectMake(centerX, centerY, 300, 50);
    CGSize size = CGSizeMake(300, 50);
    
    // Create the banner ad view and add it as a subview
    ANBannerAdView *banner = [ANBannerAdView adViewWithFrame:rect placementId:@'186f6651be1753f8' adSize:size];
    banner.rootViewController = self;
    [self.view addSubview:banner];
    
    // Load an ad!
    [banner loadAd];
}

 

Interstitial Formats

Interstitial formats are full screen and they are displayed over the app’s content. They include a solid color background and a close button at the top right corner, which allows the user to close the advertisement and continue navigating the application. To show this type of ads, you must create and instantiate an “InterstitialAd”.

Before creating an “InterstitialAd”, it is necessary to import certain controls, as it is shown in the sample code and implement the “adDidReceiveAd” delegate method. Then, the “InterstitisalAd” is created, indicating the placement ID and the selected size.

 

For your reference, please read the following chart of suggested sizes:

Smartphones

300x250 / 320x480

Tablets

900x500 / 1024x1024

 

The next example shows how to implement an Interstitial ad in an iOS Application activity.

Note that as in the previous example, in the parameter initwithPlacementId, it should indicate the placement to be displayed. This example includes 'dac0166035eda12f'.

#iimport 'FunViewController.h'
#import 'ANInterstitialAd.h'
 
@interface FunViewController () <ANInterstitialAdDelegate>
 
@property (nonatomic, strong)ANInterstitialAd *inter;
 
@end
 
@implementation FunViewController : UIViewController
 
- (void)viewDidLoad
{
    self.inter = [[ANInterstitialAd alloc] initWithPlacementId:@'dac0166035eda12f'];
 
    // set ourselves as the delegate so we can respond to the required adDidReceiveAd message of the `ANAdDelegate protocol'
    // (see implementation below)
    self.inter.delegate = self;
 
    // Load an ad!
    [self.inter loadAd];
}
 
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
 
- (void)adDidReceiveAd:(id<ANAdProtocol>)ad
{
    [self.inter displayAdFromViewController:self];
}
 
- (void)adFailedToDisplay:(ANInterstitialAd *)ad
{
    NSLog(@'Uh oh, the ad failed to display!');
}
@end

 

 

Open landing pages in native browser

By default, the landing page opens in the application. If you would like it to open in the device’s native browser, include the following line:

...

 

 

Logging Configuration

In order to visualize the requests sent to the adserver for debugging purposes, you can use the following methods to obtain the log’s output:

getANLogLevel

setANLogLevel

 

This is an example – View ANLogManager.h to obtain the different log levels:

[ANLogManager setANLogLevel:ANLogLevelDebug];