-
-
Save rainbow23/4037309 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(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