#import "iPhone_exampleAppDelegate.h"
#import "iPhone_exampleViewController.h"
@interface iPhone_exampleAppDelegate ()
- (void) AddiAd;
- (void) AddCaulyAD;
@end
@implementation iPhone_exampleAppDelegate
@synthesize window;
@synthesize viewController;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[window addSubview:viewController.view];
[window makeKeyAndVisible];
// 지역 체크!
NSString *countryCode = [[NSLocale currentLocale] objectForKey: NSLocaleCountryCode];
NSLog(@"The device's specified countryCode is %@", countryCode);
// embed AD
_isBannerVisible = NO;
if ([countryCode isEqualToString:@"KR"]) {
[self AddCaulyAD];
} else {
[self AddiAd];
}
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
}
- (void)applicationWillTerminate:(UIApplication *)application {
}
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
}
- (void)dealloc {
[window release];
[super dealloc];
}
#pragma mark - iAd
- (void) AddiAd {
ADBannerView *_bannerView = [[ADBannerView alloc] initWithFrame:CGRectZero];
CGRect _adBannerFrame = _bannerView.frame;
_adBannerFrame.origin.y = self.viewController.view.frame.size.height;
[_bannerView setFrame:_adBannerFrame];
[_bannerView setDelegate:self];
[_bannerView setAutoresizingMask:UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleRightMargin];
[_bannerView setRequiredContentSizeIdentifiers:[NSSet setWithObject:ADBannerContentSizeIdentifierPortrait]];
[self.viewController.view addSubview:_bannerView];
[_bannerView release];
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
NSLog(@"iAd AdReceiveCompleted..");
if (!_isBannerVisible) {
[UIView beginAnimations:@"animateAdBannerOn" context:nil];
[banner setFrame:CGRectOffset(banner.frame, 0, -banner.frame.size.height)];
[UIView commitAnimations];
_isBannerVisible = YES;
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
NSLog(@"iAd AdReceiveFailed..");
if (_isBannerVisible) {
[UIView beginAnimations:@"animateAdBannerOff" context:nil];
[banner setFrame:CGRectOffset(banner.frame, 0, banner.frame.size.height)];
[UIView commitAnimations];
_isBannerVisible = NO;
}
}
#pragma mark - CaulyAD
- (void)AddCaulyAD {
[CaulyViewController initCauly:self];
float yPos = self.viewController.view.frame.size.height - 48;
if( [CaulyViewController requestBannerADWithViewController:viewController xPos:0 yPos:yPos adType:BT_IPHONE] == FALSE ) {
NSLog(@"requestBannerAD failed");
}
}
- (void)AdReceiveCompleted {
NSLog(@"CaulyAD AdReceiveCompleted..");
if (!_isBannerVisible) {
[UIView beginAnimations:@"animateAdBannerOn" context:nil];
[CaulyViewController moveBannerAD:self.viewController caulyParentview:nil xPos:0 yPos:self.viewController.view.frame.size.height - 48];
[UIView commitAnimations];
_isBannerVisible = YES;
}
}
- (void)AdReceiveFailed {
NSLog(@"CaulyAD AdReceiveFailed..");
if (_isBannerVisible) {
[UIView beginAnimations:@"animateAdBannerOff" context:nil];
[CaulyViewController moveBannerAD:self.viewController caulyParentview:nil xPos:0 yPos:self.viewController.view.frame.size.height];
[UIView commitAnimations];
_isBannerVisible = NO;
}
}
- (NSString *) devKey {
return @"CAULY";
}
- (NSString *) gender {
return @"all";
}
- (NSString *) age {
return @"all";
}
- (BOOL) getGPSInfo {
return FALSE;
}
- (REFRESH_PERIOD) rollingPeriod {
return SEC_60;
}
- (ANIMATION_TYPE) animationType {
return FADEOUT;
}
@end
|