2016-12-28 2 views
0

여러 자습서를 사용해 보았지만 여러 곳에서 코드를 사용해 보았지만 Google Adob을 통해 어떤 일도 할 수 없었습니다. 시뮬레이터에서 오류가없고 프로젝트 빌드가 실행됩니다. 디버거에는 광고가로드되지 않고 메시지도 표시되지 않습니다. 기본적으로 아무 것도 일어나지 않습니다.ios8 응용 프로그램에서 작동하도록 admob을 얻을 수 없습니다.

나는 내 viewcontroller.h

[FIRApp configure]; 
[GADMobileAds configureWithApplicationID:@"ca-app-pub-5601547953982889~9365662253"]; 

을 넣었습니다

#import <GoogleMobileAds/GoogleMobileAds.h> 
#import <GoogleMobileAds/GADBannerView.h> 
#import <GoogleMobileAds/GADBannerViewDelegate.h> 
#import "Firebase.h" 

didFinishLaunchingWithOptions:(NSDictionary *)launchOptions에서 내 AppDelegate에에 다음을 추가 한 나는 또한

#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; 

내보기 controller.m 필자의 다음

@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 

- (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]]; 

확실히 다 알아서 할 수 있지만 절대적으로 아무것도 작동하지 않습니다. 오류가없고 degub, zip ...

도와주세요!

+0

Google Ad Mob 기능을 Cocoa Pods로 설치하는 대신 직접 구현 했습니까? – Mochi

+0

수동으로 수행 한 경우 모든 라이브러리에서 추가 한 내용을 코카 포드 파일에 공유하십시오. 또한 로그를 공유하십시오. 일반적으로 로그에 메시지 –

+0

이 구현되었으며 다음 프레임 워크를 추가했습니다. –

답변

0

그래서 코코아 포드로 설치하려고 시도했지만 여전히 같은 결과가있었습니다. 그런 다음 GADbannerview 파일에서 광고를로드하는 예제 코드를 발견했습니다. 이 코드를 시도했는데 이제 광고가 표시됩니다!

GADBannerView *adView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner]; 
adView.rootViewController = self; 
adView.adUnitID = @"ca-app-pub-3940256099942544/2934735716"; 
/// // Place the ad view onto the screen. 
[self.view addSubview:adView]; 
/// // Request an ad without any additional targeting information. 
[adView loadRequest:[GADRequest request]];