IOS

From Ad4Game Developers
Revision as of 10:46, 11 November 2013 by Mostapha (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Contents

Publishers

Download iOS SDK

Download the [iOS SDKv3.0 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:

  
#import <A4GPub/A4GEdito.h> @interface TestViewController : UIViewController { IBOutlet UIButton *editoButton; A4GEdito *a4gEdito; } @end

In your ViewController.m file
– In your viewDidLoad method, you need to instantiate the object created on your ViewController.h file and call the different method to display Editorials.
The methods are:
* setZoneID method, allows you to set the zoneID.
* setButton method, allows you to set your UIButton.
* showA4GEditos method, to display directly the Editorials when the app started.
* showA4GEditosWithStartTime method, to display the Editorials after a certain time.
* showA4GEditosWithStartAndEndTime method, to display the Editorials after a certain time, and close them automatically after a certain time.

Your code need to be similar to this:

   
@implementation TestViewController –(void)viewDidLoad { [super viewDidLoad]; a4gEdito = [[A4GEdito alloc] init]; [a4gEdito setZoneID : @"yourZoneID"]; [a4gEdito setButton : yourUIButton]; //in this example, its name is editoButton. [[a4gEdito getButton] addTarget : a4gEdito action : @selector(showA4GEditos) forControlEvents:UIControlEventTouchUpInside]; //this line add “showA4GEditos” action to your UIButton. [a4gEdito showA4GEditos]; //Display Editorials directly when the app started. [a4gEdito showA4GEditosWithStartTime:15]; //Display Editorials after 15 seconds. [a4gEdito showA4GEditosWithStartAndEndTime : 10 withArg2 : 30]; //Display Editorials after 10 seconds and close it automatically after 30 seconds. }

Display iOS Interstitials

To display iOS Interstitials on your iOS project, you need to follow the steps bellow:
In your ViewController.h file
- You need to import the A4GInterstitials.h header file.
- Declare an Object of A4GInterstitials.
Your code need to be similar to this:

  
#import <A4GPub/A4GInterstitials.h> @interface TestViewController : UIViewController { A4GInterstitials *a4gInter; } @end

In your ViewController.m file

- In your viewDidLoad method, you need to instantiate the object created on your ViewController.h file and call the differents method to display Interstitials.
The methods are:


* setZoneID method, allows you to set the zoneID.
* showA4GInterstitials method, to display directly the Interstitials when the app started.
* showA4GInterstitialsWithStartTime method, to display the interstitials after a certain time.
* showA4GInterstitialsWithStartAndEndTime method, to display the interstitials after a certain time, and close them automatically after a certain time.
Your code need to be similar to this:

  
@implementation TestViewController –(void)viewDidLoad { [super viewDidLoad]; a4gInter = [[A4GInterstitials alloc] init]; [a4gInter setZoneID : @"yourZoneID"]; [a4gInter showA4GInterstitials]; //Display Interstitials directly when the app started. [a4gInter showA4GInterstitialsWithStartTime:15]; //Display Interstitials after 15 seconds. [a4gInter showA4GInterstitialsWithStartAndEndTime : 10 withArg2 : 30]; //Display Interstitials after 10 seconds and close them automatically after 30 seconds. }

Advertisers

Download iOS SDK

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

Include the A4GTrack.framework

To include the A4GTrack.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 A4GTrack.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 internet availability.
Go to Build Phases → Link Binary With Libraries, then click on the + sign to add the SystemConfiguration.framework.

Tracking installations

In your appDelegate.m, you need to import the A4GTrack.framework
#import <A4GTrack/A4GTrackViewController.h>
In your didFinishLaunchingWithOptions method, you need to call the trackInstall method thatallow you tracking installations once per user.
[ A4GTrackViewController trackInstall:@"yourTrackerID"].

Contact

If you've got questions, we've got answers! Please Contact Us at tech@ad4game.com with any technical queries.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox