0
我已经尝试了多个教程,并尝试了多个地方的代码,但无法让Google admob执行任何操作。我没有得到任何错误,项目构建并在模拟器中运行。调试器中没有广告加载和消息。 基本上什么都没有发生。无法让admob在ios8应用程序上工作
我已在我的appDelegate以下
#import <GoogleMobileAds/GoogleMobileAds.h>
#import <GoogleMobileAds/GADBannerView.h>
#import <GoogleMobileAds/GADBannerViewDelegate.h>
#import "Firebase.h"
下didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
我已经把
[FIRApp configure];
[GADMobileAds configureWithApplicationID:@"ca-app-pub-5601547953982889~9365662253"];
在我viewcontroller.h
我还添加了
#import <GoogleMobileAds/GoogleMobileAds.h>
#import <GoogleMobileAds/GADBannerView.h>
#import <GoogleMobileAds/GADBannerViewDelegate.h>
#import "Firebase.h"
添加
@interface BT_viewController : UIViewController <GADBannerViewDelegate,
和
@property (nonatomic, weak) IBOutlet GADBannerView *bannerView;
和
@protocol GADBannerViewDelegate <NSObject>
@optional
- (void)adViewDidReceiveAd:(GADBannerView *)bannerView;
- (void)adView:(GADBannerView *)bannerView
didFailToReceiveAdWithError:(GADRequestError *)error;
- (void)adViewWillPresentScreen:(GADBannerView *)bannerView;
- (void)adViewDidDismissScreen:(GADBannerView *)bannerView;
- (void)adViewWillDismissScreen:(GADBannerView *)bannerView;
- (void)adViewWillLeaveApplication:(GADBannerView *)bannerView;
@end
在我看来Controller.m或者香港专业教育学院
然后加入
- (void)adViewDidReceiveAd:(GADBannerView *)bannerView {
bannerView.hidden = NO;
[BT_debugger showIt:self theMessage:@"Google ad shown"];
}
- (void)adView:(GADBannerView *)bannerView didFailToReceiveAdWithError: (GADRequestError *)error {
NSLog(@"adView:didFailToReceiveAdWithError: %@", error.localizedDescription);
}
,然后-(void)viewDidLoad
下我加
self.bannerView = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
self.view.frame.size.height -
GAD_SIZE_320x50.height,
GAD_SIZE_320x50.width,
GAD_SIZE_320x50.height)];
self.bannerView.delegate = self;
self.bannerView.adUnitID = @"ca-app-pub-3940256099942544/2934735716";
self.bannerView.rootViewController = self;
[self.view addSubview:self.bannerView];
[self.bannerView loadRequest:[GADRequest request]];
很确定我把它全部覆盖,但绝对没有什么工作。没有错误,没有软化剂,拉链...
请帮助!
您是否自己实施了Google Ad Mob功能,而不是通过Cocoa Pod进行安装? – Mochi
请分享您的古柯豆荚文件,如果您手动完成,所有库都添加了什么?还分享日志。通常日志显示消息 –
我实施了自己并添加了以下框架 –