- How to Add the RadiumOne SDK files to your Project
- Linking to the Dependency Frameworks
- Integrating with Your Code
- Setting up your App Delegate
- Integrating with Interface Builder
- Integrating without Interface Builder
- Working with Ads
- Pause ad requests when your view disappears
- Resume ad requests when your view appears
- Canceling and releasing ad view
- Receive information from Ad View
- Integrating Full Screen Ads
- Requesting Ads and Manually Displaying
- Requesting Ads and Automatically Displaying
This document describes how to integrate the RadiumOne publisher SDK for iOS into your application.
This document describes how to:
- Add the Mobclix SDK files to your project
- Integrate with Interface Builder
- Integrate without Interface Builder
- Integrate Your Code and set up App Delegate
Before you start, you should have the following files:
RadiumOneSDK | Contains the RadiumOne SDK for iOS |
DemoApplication | Fully functional iOS application that integrates all features of the RadiumOne SDK. |
documentation | SDK integration guide to help new developers integrate the RadiumOne SDK for iOS into their applications. This is the document that you are now reading. |
- Open up your iOS project in xCode.
- Select File -> Add Files to “[your project]”
- Select Folder with SDK library and headers in dialog
- When the dialog box appears, check the Copy Items into destination group’s folder checkbox.
To correct linking you must add few required frameworks:
You will need to initialize RadiumOne SDK in your App Delegate.
- At the top of this file you should add
#import "RadiumOneAd.h"
- You should find applicationDidFinishLaunching: method, or application:didFinishLaunchingWithOptions: method and insert
[RadiumOneAd startWithApplicationId:@"your-application-id"];
#import "RadiumOneAppDelegate.h"
#import "RadiumOneRootViewController.h"
#import "RadiumOneAd.h"
@implementation RadiumOneAppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[RadiumOneAd startWithApplicationId:@"your-application-id"];
// Your initialization code here
return YES;
}
// Other methods
@end
- Set up your Interface file ([Your view controller].h) with “adView” as an outlet:
#import <UIKit/UIKit.h>
#import "RadiumOneAdView.h"
@interface YourViewController : UIViewController
{
RadiumOneAdView *adView;
}
@property (nonatomic, retain) IBOutlet RadiumOneAdView *adView;
@end
- Set up your Implementation file ([Your view controller].m):
@implementation YourViewController
@synthesize adView;
- Set up your Interface Builder file ([Your view controller].xib):
3.1. Add new view into main view
3.2. Set up class for this view (RadiumOne320x50AdView for 320x50 banner, RadiumOne300x250AdView for 300x250 banner and RadiumOne728x90AdView for iPad 728x90 banner):
3.3. Set up ad view size and layout:
3.4. Connect this view with adView object:
3.5. Go to the section “Working with Ads” in this document.
- Set up your Interface file ([Your view controller].h) with “adView” as an outlet:
#import <UIKit/UIKit.h>
#import "RadiumOneAdView.h"
@interface YourViewController : UIViewController
{
RadiumOneAdView *adView;
}
@property (nonatomic, retain) RadiumOneAdView *adView;
@end
- Set up your Implementation file ([Your view controller].m):
#import "YourViewController.h"
@implementation YourViewController
@synthesize adView;
- (void) viewDidLoad
{
[super viewDidLoad];
self.adView = [[[RadiumOne320x50AdView alloc]
initWithFrame:CGRectMake(0, 0, 320, 250)] autorelease];
[self.view addSubview:self.adView];
}
@end
- Go to the section “Working with Ads” in this document.
In your view controller’s viewDidDisappear
method, you should stop the ad refreshing timer by calling pauseAdAutoRefresh
. If you don’t make this all view controllers with banners will always update content.
- (void) viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
[self.adView pauseAdAutoRefresh];
}
In your view controller’s viewWillAppear
method, you should start the ad refresh timer by calling resumeAdAutoRefresh
.
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.adView resumeAdAutoRefresh];
}
- (void) dealloc
{
[self.adView cancelAd];
self.adView = nil;
[super dealloc];
}
- (void) viewDidUnload
{
[self.adView cancelAd];
[self.adView removeFromSuperview];
self.adView = nil;
[super viewDidUnload];
}
If you want receive information about Ads loading or errors you can use optional delegate.
- (void) viewDidLoad
{
// Your code and adView initialization
self.adView.delegate = (id)self;
}
Now you can add optional delegate methods into your code:
- (void) adViewDidFinishLoad:(RadiumOneAdView*)adView
{
// Ad view loads the banner
}
- (void) adView:(RadiumOneAdView*)adView
didFailLoadWithError:(NSError*)error
{
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Error" message:[error localizedDescription]
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
The method adViewDidFinishLoad:
called after adView loaded the banner.
The methods adView:didFailLoadWithError:
called when something bad happened:
- adView can not receive information from server
- adView received information but can not parse it
- adView received information without supported banners
- Set up your Interface file ([Your view controller].h) with “fullScreenAdViewController”:
#import <UIKit/UIKit.h>
#import "RadiumOneFullScreenAdViewController.h"
@interface YourViewController : UIViewController <
RadiumOneFullScreenAdViewControllerDelegate >
{
RadiumOneFullScreenAdViewController *fullScreenViewController;
}
@property (nonatomic, retain) RadiumOneFullScreenAdViewController
*fullScreenViewController;
@end
- Set up your Implementation file ([Your view controller].m):
#import "YourViewController.h"
@implementation YourViewController
@synthesize fullScreenViewController;
- (void) dealloc
{
self.fullScreenViewController = nil;
[super dealloc];
}
@end
- Now you can use it in 2 different cases.
In this case RadiumOneFullScreenAdViewController
not opened automatically after content will be loaded.
- (void) startAdPreloading
{
self.fullScreenViewController =
[[[RadiumOneFullScreenAdViewController alloc] init] autorelease];
self.fullScreenViewController.delegate = self;
[self.fullScreenViewController requestAd];
}
// Start only after fullScreenAdViewControllerDidFinishLoad: methods was called
- (void) showAd
{
[self.fullScreenViewController
displayRequestedAdFromViewController:self];
}
- (void)
fullScreenAdViewControllerDidFinishLoad:(RadiumOneFullScreenAdViewController*) fullScreenAdViewController
{
// The Ad preloaded
}
- (void)
fullScreenAdViewController:(RadiumOneFullScreenAdViewController*)
fullScreenAdViewController didFailToLoadWithError:(NSError*) error
{
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Error" message:[error localizedDescription]
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
self.fullScreenViewController = nil;
}
- (void)
fullScreenAdViewControllerDidDismiss:(RadiumOneFullScreenAdViewController*) fullScreenAdViewController
{
self.fullScreenViewController = nil;
}
In this case RadiumOneFullScreenAdViewController
opened automatically after content will be loaded.
- (void) preloadAndOpenAd
{
self.fullScreenViewController =
[[[RadiumOneFullScreenAdViewController alloc] init] autorelease];
self.fullScreenViewController.delegate = self;
[self.fullScreenViewController
requestAndDisplayAdFromViewController:self];
}
- (void)
fullScreenAdViewController:(RadiumOneFullScreenAdViewController*)
fullScreenAdViewController didFailToLoadWithError:(NSError*) error
{
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Error" message:[error localizedDescription]
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
self.fullScreenViewController = nil;
}
- (void)
fullScreenAdViewControllerDidDismiss:(RadiumOneFullScreenAdViewController*) fullScreenAdViewController
{
self.fullScreenViewController = nil;
}