iOS Banner Ad

This section describes how to integrate with the AdFalcon’s iOS SDK in order to consume the services available by the network.

In order to integrate with the SDK, please perform the following steps:

Add ADFAdView to your ViewController

  1. Add ADFAdView to the view controller header file
    1. Import AdFalconSDK
    2. declare ADFAdView instance.

Below is an example of how the header should look like:

@import "AdFalconSDK";

@interface XViewController: UIViewController{
     ADFAdView * adView;
}

  1. Add the following code snippet to viewDidLoad method
//initialize ADFalcon view and set size of the view base on ad unit size
	adView = [[ADFAdView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];

	//Enable or disable testing mode
	adView.testing = YES;

	//initialize AdFalcon view and loading ads
	[adView 

	   initializeWithAdUnit:kADFAdViewAdUnitSizeAutoBanner //set the ad unit size

             	siteId:@"Your Site ID"

             	params:nil //Optional set user information

             	rootViewController:self //rootViewController

             	enableAutorefresh:YES //Enable or disable auto refresh

             	delegate:nil //Optional

	];

	//Add AdFalcon view
	[self.view addSubview:adView];

Note: In case you are overriding the [UIViewController loadView] to programmatically draw your view, ensure that AdFalcon view is initialized after completing loading the UIViewController’s view.

Note: Ensure Test Mode Parameter is set to false before uploading your application to Apple store.

Note: to know more about ad unit size go to ADFAdViewAdUnitSize

Ads Options

Tracking Ad Lifecycle Events – ADFADViewDelegate

AdFalcon iOS SDK provides ability to track Ad lifecyle events, follow the procedure below to listen to the Ad lifecycle events

  • Import the ADFADViewDelegate.h protocol to your header as the below:
@import "AdFalconSDK";

@interface XViewController: UIViewController {
}

  • Add the below ADFADViewDelegate’s methods to your source file as the below
-(void)adViewWillLoadAd:(ADFAdView*) adView
{
}
-(void)adViewDidLoadAd: (ADFAdView*) adView
{
}
-(void)adView: (ADFAdView*) adView didFailWithCode:(int) code message:(NSString*) message
{
    switch (code) {
        case kADFAdViewErrorNoAdAvailabe:
            // No Ad Availabe
            break;
        case kADFAdViewErrorInvalidParam:
            // Invalid Param send to server
            break;
        case kADFAdViewErrorMissingParam:
            // Missing Param send to server
            break;
        case kADFAdViewErrorCommunication:
            //Communication with server failed or no internet
            break;
        default:
            break;
    }
}
-(void)adViewWillPresentScreen: (ADFAdView*) adView
{
}
-(void)adViewDidPresentScreen: (ADFAdView*) adView
{
}
-(void)adViewWillDismissScreen: (ADFAdView*) adView
{
}
-(void)adViewDidDismissScreen: (ADFAdView*) adView
{
}
-(void)applicationWillTerminate:(UIApplication *)application
{
}
-(void)applicationWillEnterBackground:(UIApplication *)application
{
}

  • Assign your delegate object to ADFAdView object as the below:
	[adView initializeWithAdUnit:kADFAdViewAdUnitSizeAutoBanner //set the ad unit size

             	siteId:@"Your Site ID"

             	params:nil //Optional set user information

             	rootViewController:self //rootViewController

             	enableAutorefresh:YES //Enable or disable auto refresh

             	delegate:self  //Optional

	];

OR

	adView.delegate = self;

Select Ad Unit Size

Use the below enum table to select the needed ad unit size

Enum Description Size Devices
kADFAdViewAdUnitSizeAutoBanner The server will return the best banner ad based on the screen size and device type All
kADFAdViewAdUnitSize320x50 Standard 320 x 50 All
kADFAdViewAdUnitSize300x250 Medium Rectangle 300 x 250 All
kADFAdViewAdUnitSize468x60 Full Banner 468 x 60 Tablet
kADFAdViewAdUnitSize728x90 Leaderboard 728 x 90 Tablet
kADFAdViewAdUnitSize120x600 Skyscraper 120 x 600 Tablet

Refresh Ad

Use the below methods to enable, pause, resume or force refresh Ad.

Method Description
-(void) initializeWith

AdUnit:(ADFAdViewAdUnitSize) adUnit

siteId:

(NSString*) siteId

userInfo:

(ADFUserInfo*) userInfo

rootViewController:

(UIViewController*) rootViewController

enableAutorefresh:

(BOOL) enableAutorefresh                       delegate:

(NSObject *) delegate;

Enable or disable auto refresh ad
-(void) pauseAutoRefresh; Will pause auto refresh timer which is responsible for getting new ad the ad after a certain period has elapsed.
-(void) resumeAutoRefresh; Will resume the auto refresh timer which responsible for getting new ad after a certain period has elapsed.
-(void) refreshAd; Will get a new ad from AdFalcon.