2013-05-03 77 views
5

我在iOS應用上實施Admob。Admob測試設備未顯示模擬器udid

我剛剛下載AdMob聯播示例代碼,當我試圖在模擬器上運行它,我的控制檯是說"To get test ads on this device, call: request.testDevices = NSArray arrayWithObjects:@"GAD_SIMULATOR_ID", nil];」。

所以,我說我的Mac UDID和測試設備UDID到一個數組並將其設置爲請求。但是,應用程序仍然顯示默認橫幅,而不是我的admob帳戶中的廣告。此外,控制檯也提供了同樣的上述消息。有沒有人知道我在這裏丟失了什麼?這裏是代碼。

self.adBanner = [[[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner 
               origin:origin]; 
self.adBanner.adUnitID = kSampleAdUnitID; 
self.adBanner.delegate = self; 
[self.adBanner setRootViewController:self]; 
[self.view addSubview:self.adBanner]; 
self.adBanner.center = CGPointMake(self.view.center.x, self.adBanner.center.y); 
GADRequest *request = [GADRequest request]; 
request.testing = YES; 
request.testDevices = [NSArray arrayWithObjects: @"XXXX-XXXX-XXXX-XXXX-XXXXXXXX", 
              @"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 
              nil]; 
[self.adBanner loadRequest:request]; 

順便說一下,我將kSampleAdUnitID替換爲我的Admob發佈商ID和XXX,其中m y mac id和設備ID。

+0

https://developers.google.com/mobile-ads-sdk/docs/admob/intermediate – 2013-05-03 04:24:06

回答

0

其實,你並不需要添加testDevices能夠獲得的廣告
我還沒有收到廣告,但是當我刪除的testDevices我的DeviceID,它的工作原理
順便說一句,如果你想添加模擬器ID只需使用@"GAD_SIMULATOR_ID",這是模擬器的默認ID,您只需要真實設備的真實ID。

8

啓用測試廣告

在您的iDevice,進入設置>隱私>廣告和禁用「限制廣告跟蹤」選項。然後,當您在硬件上運行應用程序時,請檢查Xcode的控制檯:您將看到可以添加到testDevices數組的ID。

0

您需要的Devce Id是您手機的廣告標識符的MD5散列。我下載了一個名爲'標識符'link here的應用程序,它爲您提供所有您需要的信息。

在createView方法中,將廣告標識的MD5散列添加到testDevices數組中,然後您將在應用中看到添加。

var ad1 = Admob.createView({ 
      height: 50, 
      top: 0, 
      debugEnabled: true, // If enabled, a dummy value for `adUnitId` will be used to test 
      adType: Admob.AD_TYPE_BANNER, 
      adUnitId: 'ca-app-pub-000000xxxxxxxxxx/8204200000', // You can get your own at http: //www.admob.com/ 
      adBackgroundColor: 'black', 
      testDevices: [Admob.SIMULATOR_ID,'xxxc8xx0xxxccxxb4a12cxxxxxxxxxxx'], // You can get your device's id by looking in the console log 
       dateOfBirth: new Date(1985, 10, 1, 12, 1, 1), 
       gender: Admob.GENDER_MALE, // GENDER_MALE or GENDER_FEMALE default: undefined 
      contentURL: 'https://admob.com', // URL string for a webpage whose content matches the app content. 
      requestAgent: 'Titanium Mobile App', // String that identifies the ad request's origin. 
    extras: { 
     'version': 1.0, 
     'name': 'Eyespy' 
    }, // Object of additional infos 
    tagForChildDirectedTreatment: false, // http:///business.ftc.gov/privacy-and-security/childrens-privacy for more infos 
    keywords: ['keyword1', 'keyword2'] 
    }); 

    $.adview.add(ad1); 
相關問題