Skip to content

Instantly share code, notes, and snippets.

@rainbow23
Forked from ryozaki/gist:1363541
Created November 8, 2012 07:00
Show Gist options
  • Save rainbow23/4037309 to your computer and use it in GitHub Desktop.
Save rainbow23/4037309 to your computer and use it in GitHub Desktop.
-(void) registerAdmob
{
NSLog(@"-> registerAdmob initializing Admob start");
UnityViewController* controller = (UnityViewController*)UnityGetGLViewController();
EAGLView* view = (EAGLView*)[controller view];
NSLog(@"EAGLView frame size:(%f, %f)", view.frame.size.width, view.frame.size.height);
CGFloat scaleSize = [UIScreen mainScreen].scale;
NSLog(@"UIScreen scale:%f", scaleSize);
CGFloat screenWidth = view.frame.size.height * scaleSize;
CGFloat bannerWidth = GAD_SIZE_320x50.width;
NSLog(@"screenWidth:%f, bannerSize:%f", screenWidth, bannerWidth);
_bannerView = [[GADBannerView alloc]
initWithFrame:CGRectMake((view.frame.size.height - bannerWidth),
0.0,
GAD_SIZE_320x50.width,
GAD_SIZE_320x50.height)];
_bannerView.adUnitID = @"xxxxxxxxxxx";
_bannerView.rootViewController = controller;
[controller.view addSubview:_bannerView];
GADRequest* r = [GADRequest request];
r.testDevices = [NSArray arrayWithObjects:
@"テストデバイスID", // Test iPhone 3G 3.0.1
nil];
[_bannerView loadRequest:r];
NSLog(@"-> initializing Admob end");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment