AdWhirl 3.0 + AdMob (iPhone+iPad App) 設置方法
如果你正在尋找如何設置 AdWhirl SDK到XCode Project 可參看 AdWhirl 3.0 + AdMob (iPhone+iPad App) 設置方法。
要 AdWhirl與 AdMob的支援你的Universal App,使其同時在iPhone和iPad正常顯示,首先需要在AdMob 及AdWhirl把App 加入成兩個單獨的App,一個用於 iPhone和一個 iPad的。故先轉到 AdMob的,添加App兩次,獲得將舉兩個Publisher ID。把這兩個Publisher ID在AdWhirl中在相應的App Profile 中設置。最後您將有兩個 AdWhirl App,一個是iPhone 的,另一個iPad的,並在每個其中,有相應的AdMob Publisher ID。
在 AdWhirlViewDelegate class 的 adWhirlApplicationKey method,傳回iPhone/iPad相應的AdWhirl SDK Key,如下(請把Your_AdWhirl_SDK_Key_for_iPhone和Your_AdWhirl_SDK_Key_for_iPad改成您兩個AdWhirl SDK Key):
//AdWhirlViewDelegate - (Nsstring *)adWhirlApplicationKey { if (UI_USER_INTERFACE_IdioM() == UIUserInterfaceIdiomPhone) { return @"Your_AdWhirl_SDK_Key_for_iPhone"; } else { return @"Your_AdWhirl_SDK_Key_for_iPad"; } }
在 AdWhirl SDK 3.0中的AdMob adapter “AdWhirlAdapterGoogleAdMobAds.m”,更改getAd() method:
在method 的開端加入:
//Request the right size ad for your device CGSize adSize = GAD_SIZE_320x50; if (UI_USER_INTERFACE_IdioM() == UIUserInterfaceIdiomPad) adSize = GAD_SIZE_728x90; CGRect adFrame = CGRectMake(0,adSize.width,adSize.height);
在method 中找這一行
GADBannerView *view = [[GADBannerView alloc] initWithFrame:kAdWhirlViewDefaultFrame];
改成:
GADBannerView *view = [[GADBannerView alloc] initWithFrame:adFrame];
以下是更改完成後的getAd() method:
- (void)getAd { //Request the right size ad for your device CGSize adSize = GAD_SIZE_320x50; if (UI_USER_INTERFACE_IdioM() == UIUserInterfaceIdiomPad) adSize = GAD_SIZE_728x90; CGRect adFrame = CGRectMake(0,adSize.height); GADRequest *request = [GADRequest request]; NSObject *value; NSMutableDictionary *additional = [NSMutableDictionary dictionary]; if ([adWhirlDelegate respondsToSelector:@selector(adWhirlTestMode)] && [adWhirlDelegate adWhirlTestMode]) { [additional setobject:@"on" forKey:@"adtest"]; } if ((value = [self delegateValueForSelector: @selector(adWhirlAdBackgroundColor)])) { [additional setobject:[self hexStringFromUIColor:(UIColor *)value] forKey:@"color_bg"]; } if ((value = [self delegateValueForSelector: @selector(adWhirlAdBackgroundColor)])) { [additional setobject:[self hexStringFromUIColor:(UIColor *)value] forKey:@"color_text"]; } // deliberately don't allow other color specifications. if ([additional count] > 0) { request.additionalParameters = additional; } CLLocation *location = (CLLocation *)[self delegateValueForSelector:@selector(locationInfo)]; if ((adWhirlConfig.locationOn) && (location)) { [request setLocationWithLatitude:location.coordinate.latitude longitude:location.coordinate.longitude accuracy:location.horizontalAccuracy]; } Nsstring *string = (Nsstring *)[self delegateValueForSelector:@selector(gender)]; if ([string isEqualToString:@"m"]) { request.gender = kGADGenderMale; } else if ([string isEqualToString:@"f"]) { request.gender = kGADGenderFemale; } else { request.gender = kGADGenderUnkNown; } if ((value = [self delegateValueForSelector:@selector(dateOfBirth)])) { request.birthday = (NSDate *)value; } if ((value = [self delegateValueForSelector:@selector(keywords)])) { request.keywords = [NSMutableArray arrayWithArray:(NSArray *)value]; } GADBannerView *view = [[GADBannerView alloc] initWithFrame:adFrame]; view.adUnitID = [self publisherId]; view.delegate = self; view.rootViewController = [adWhirlDelegate viewControllerForPresentingModalView]; self.adNetworkView = [view autorelease]; [view loadRequest:request]; }
有了上面的設置和修改,iPhone 和iPad都能顯示正確的廣告尺寸,甚至iAD。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。