IOS

From Ad4Game Developers
Revision as of 13:23, 13 August 2013 by Mostapha (Talk | contribs)

Jump to: navigation, search

Contents

Publishers

Download iOS SDK

Download the [iOS SDK for publishers]. Decompress the zip file and extract the files to your development mac.
The Ad4game iOS SDK is provided as a single framework file (A4GPub.framework), making it easy to include in your iOS project.

Include the A4GPub.framework

To include the A4GPub.framework to your xcode project, you need to select your target project, and then go to Build Phases → Link Binary With Libraries,
then click on the + sign → Add Other, and select the A4GPub.framework saved on your mac as shown below:

Include the AdSupport.framework

You need to include the AdSupport.framework to your project target to enable the Advertiser Identifier functionality. Go to Build Phases → Link Binary With Libraries, then click on the + sign to add the AdSupport.framework as shown below:

Then, change the value of AdSupport.framework from Required to Optional.

Include the SystemConfiguration.framework

You need to include the SystemConfiguration.framework to your project target to enable detection of the connection type. Go to Build Phases → Link Binary With Libraries, then click on the + sign to add the SystemConfiguration.framework.

Include the QuartzCore.framework

You need to include the QuartzCore.framework to your project target to customize the interface.
Go to Build Phases → Link Binary With Libraries, then click on the + sign to add the QuartzCore.framework.

Display Mobile Ads

To display ads on your iOS project, you need to follow the steps bellow:
In your ViewController.xib
– You need to add an UIImageView with the size of the ad.
– You need to add an UIButton above the UIImageView with the same size of the ad.
Connect the UIImageView and the UIButton to your ViewController.h file.

In your ViewController.h file
– You need to import the A4GPub.framework.
– Declare an Object of A4GPubViewController.
Your code need to be similar to this:

    
#import <A4GPub/A4GPubViewController.h> @interface TestViewController : UIViewController { IBOutlet UIImageView *image; A4GPubViewController *a4g; } - (IBAction)button : (id)sender; @end

In your ViewController.m file
– You need to import the A4GPub.framework.
– In your viewDidLoad method, you need to instantiate the object created on viewController.h file and call the different method to display ads.
The methods are:
* setZoneID method allows you to set the zoneID.
* setImageView method allows you to set your UIImageView.
* getRefresh method to refresh the display of banners.
* loadAds method to get banners from ad4game servers.

Your code need to be similar to this:

    
#import <A4GPub/A4GPubViewController.h> @implementation TestViewController – (void)viewDidLoad { [super viewDidLoad]; a4g = [[A4GPubViewController alloc] init]; [a4g setZoneID : @"yourZoneID"]; [a4g setImageView : yourUIImageView]; //in this example, its name is image [a4g getRefresh]; [a4g loadAds]; }

– In your ­ (IBAction)button : (id)sender method, you need to call the loadClick method allowing you to get the click associate to the ad displayed.

   
– (IBAction)button : (id)sender { [a4g loadClick]; }
  
Note: You can add many zones as you want, just instantiate the A4GPubViewController object as follow :

In your ViewController.h :

  
#import <A4GPub/A4GPubViewController.h> @interface TestViewController : UIViewController { IBOutlet UIImageView *imageOne; IBOutlet UIImageView *imagetwo; A4GPubViewController *a4gObject; A4GPubViewController *secondObject; } – (IBAction)buttonOne : (id)sender; – (IBAction)buttonTwo : (id)sender; @end

In your ViewController.m :

   
#import <A4GPub/A4GPubViewController.h> @implementation TestViewController -(void)viewDidLoad { [super viewDidLoad]; a4gObject = [[A4GPubViewController alloc] init]; secondObject = [[A4GPubViewController alloc] init]; [a4gObject setZoneID : @"FirstZoneID"]; [a4gObject setImageView : yourUIImageView]; [a4gObject getRefresh]; [a4gObject loadAds]; [secondObject setZoneID : @"SecondZoneID"]; [secondObject setImageView : yourUIImageView]; [secondObject getRefresh]; [secondObject loadAds]; } – (IBAction)buttonOne : (id)sender { [a4gObject loadClick]; } – (IBAction)buttonTwo : (id)sender { [secondObject loadClick]; }

Display iOS Editorials

To display iOS Editorials on your iOS project, you need to follow the steps bellow:

In your ViewController.xib
You need to add a UIButton if you want to launch the editorials when the user clicks on that button.
Connect the UIButton to your ViewController.h file.

In your ViewController.h file
– You need to import the A4GEdito.h header file.
– Declare an Object of A4GEdito.
Your code need to be similar to this:

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox