2013-10-22 36 views
9

雖然我在模擬器測試AdMob後,它會引發下面誤差要在此設備上獲得測試廣告,請調用:request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID,nil];

向該設備上獲得測試廣告,撥打:request.testDevices = [NSArray的arrayWithObjects:GAD_SIMULATOR_ID,零]。

我的代碼

bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner]; 
bannerView_.adUnitID = @"8de66ecc3525495d"; 

bannerView_.rootViewController = self; 
[self.view addSubview:bannerView_]; 

GADRequest *request = [[GADRequest alloc] init]; 
request.testing = YES; 
[bannerView_ loadRequest:request]; 

引導我去存檔。在此先感謝..

回答

4

在最後修正錯誤啦..

我犯的錯誤,產生adUnitId設置。所以只有我無法看到廣告。

現在從xxxx站點獲取一個adUnitID進行測試。它的工作很好..

adUnitID = @"a14dccd0fb24d45"; 

感謝所有支持者。

0

我曾經這樣做:

GADRequest *request = [GADRequest request]; 

// Make the request for a test ad. Put in an identifier for 
// the simulator as well as any devices you want to receive test ads. 
request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, nil]; 
[gAdBannerView loadRequest:request]; 

,我定義

// Constant for getting test ads on the simulator using the testDevices method. 
#define GAD_SIMULATOR_ID @"Simulator" 
+1

再次相同的錯誤來了。 –

+0

對不起,我不知道你爲什麼總是得到這個錯誤。一個問題:您的橫幅是否顯示...?或者你沒有看到任何橫幅? – Mick

+0

我沒有得到任何橫幅,只顯示空白屏幕。其實我在模擬器中運行這個代碼。這有什麼問題嗎? –

0
我目前使用這個

。即使在模擬器中也適用於我。我得到了這個錯誤,但這不是一個錯誤,我廣泛搜索並發現它更多的是一個信息性的消息。

當測試模式設置爲NO時,主要的觀點是讓測試模式設置爲NO時顯示真實廣告,當測試模式設置爲YES時,顯示「成功,您現在準備好去旅行廣告銀河」消息。因此,如果您在應用程序中有任何結果,則應該沒問題。 :)

我的代碼如下:

GADBannerView *bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner]; 

bannerView_.adUnitID = GOOGLE_UNIT_ID; 

GADRequest *request = [GADRequest request]; 

bannerView_.delegate = self; 

bannerView_.rootViewController = self; 

// Make the request for a test ad. Put in an identifier for 
// the simulator as well as any devices you want to receive test ads. 
request.testDevices = [NSArray arrayWithObjects: 
         GAD_SIMULATOR_ID, 
         nil]; 

// Initiate a generic request to load it with an ad. 
[bannerView_ loadRequest:request]; 

我沒有設置爲測試作爲YES。我的Google AdMobs SDK版本爲6.5.1

由於您提到您需要生產幫助,因此無論如何都不應將其設置爲測試模式,因此您應該可以在沒有測試模式的情況下運行它。

看看是否在模擬器或真實設備上運行並不重要,它應該在兩個設備上運行。我設置委託自我在我的代碼,因此,如果你這樣做,你可以使用的方法:

- (void) adView: (GADBannerView*) view didFailToReceiveAdWithError: (GADRequestError*) error 
- (void) adViewDidReceiveAd: (GADBannerView*) view 

在運行時,這些可以幫助你,檢查是否已收到的廣告在所有偶數模擬器。

希望這會有所幫助! :)

2

這個工作對我來說:

(GADRequest *)request { 
    GADRequest *request = [GADRequest request]; 
    // Make the request for a test ad. Put in an identifier for the simulator as well as any devices 
    // you want to receive test ads. 
    request.testDevices = @[ 
    // TODO: Add your device/simulator test identifiers here. Your device identifier is printed to 
    // the console when the app is launched. 
    GAD_SIMULATOR_ID 
    ]; 
    return request;//thanks 
} 
+2

我用request.KGADrequest取代了GAD_SIMULATOR_ID,它對我有用^^ – samouray

15

你必須添加您的測試設備。 隨着斯威夫特,只需更換

bannerView.load(GADRequest()) 

let request: GADRequest = GADRequest() 
request.testDevices = [kGADSimulatorID] 
bannerView.load(request) 

如果你有一個iPhone,然後運行該應用程序也和它會告訴你的ID:

要獲得測試廣告在此設備上,請調用:request.testDevices = @ [@「HERE IS ID」];

ID加入:

let request: GADRequest = GADRequest() 
request.testDevices = ["PUT HERE THE ID", kGADSimulatorID] 
bannerView.load(request) 

乾杯, 保羅

+1

真正的問題是爲什麼谷歌示例是錯誤的,沒有正確的評論,爲什麼調試信息中的建議會誤導... – ingconti

+1

在當前版本的swift,loadRequest已經改變爲加載。 –

+0

@TimS。謝謝,更新了答案;) – Spipau

相關問題