Google DFP creatives randomly display although correct ad tags are accessed

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 06:17:29

问题


I am using Google DFP (DoubleClick for Publishers) ads for android and iPhone devices, I want to display ads on a specific screen sizes for an app in ios and android in LANDSCAPE MODE. I have created an order then I have created a line item for that order and inside that line item, I created "creatives" of various sizes according to physical sizes of the screens for both ios and android. Then I went to inventory and got ad tags for all the creatives and incorporated them in my apps separated by size checks.

Now the issue I am facing is that in code, although the correct ad tag is accessed but the creative(image) I specified for that tag is randomly picked. This issue exists both in android and iPhone.

I want to know why not only the specified size creative (image) is picked? Is it necessary to separate the iPhone and Android inventories (creatives)?

I have also tried the smart banner sizes and cutom banner sizes but specified creative not displayed.

ref smart banners: https://developers.google.com/mobile-ads- sdk/docs/dfp/android/banner#smart

ref custom banners: https://developers.google.com/mobile-ads- sdk/docs/dfp/android/banner#custom_size

Also, when I turn on test ads, they appear on the whole width of any device but my ads are not displayed on the whole width. Although if the test ad is smaller from the width of the device, then it automatically adds some background on both sides of the ad to fill the whole width. but this not occur when my creatives are displayed.

codes for Android and iPhone: Android: To pick respective screen size ads

    Fragment frag=new AdBannerFragment();
ArrayList<Integer> screenSize=Globals.getScreenSize

(getActivity());
Integer width=screenSize.get(0);
if (width==120) {

frag = new AdBannerFragment

("/235389899/Clubfitting-Update-15_320x50-120dpi");
} else if (width==160) {
frag = new AdBannerFragment

("/235389899/Clubfitting-Update-15_320x50-160dpi");
} else if (width==240) {
frag = new AdBannerFragment

("/235389899/Clubfitting-Update-15_320x50-240dpi");
} 
else if (width==320) {
// frag = new AdBannerFragment

("/235389899/Clubfitting_4-14_320x50");
frag = new AdBannerFragment

("/235389899/Clubfitting-Update-15_320x50-320dpi");
} else if (width==480) {
// frag = new AdBannerFragment

("/235389899/Clubfitting_4-14_480x50");
frag = new AdBannerFragment

("/235389899/Clubfitting-Update-15_320x50-480dpi");

} else if (width==640){
// frag = new AdBannerFragment

("/235389899/Clubfitting_4-14_640x100");
frag = new AdBannerFragment

("/235389899/Clubfitting-Update-15_320x50-640dpi");
}else{
frag = new AdBannerFragment

("/235389899/Clubfitting-Update-15_320x50-640dpi");
}

AdBanner Fragment code(To set and load banners):

AdSize customAdSize = new AdSize(AdSize.FULL_WIDTH, 50);
adView = new PublisherAdView(activity2);
//I have also tried smart banners.
adView.setAdSizes(customAdSize);
mAdContainer.addView(adView);
adView.setAdUnitId(mTag);
adView.loadAd(new PublisherAdRequest.Builder

().build());

iPhone: To pick respective screen size ads

CGSize screenSize;

    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0"))
    {
        screenSize = [UIScreen mainScreen].nativeBounds.size;
    }
    else
    {
        screenSize = [UIScreen mainScreen].bounds.size;
    }

    NSLog(@"screen size: %@ banner frame: %@",NSStringFromCGSize(screenSize),NSStringFromCGSize(self.bannerVw.frame.size));

    if (screenSize.width== 1920)
    {
        self.bannerVw.adUnitID = @"/235389899/Clubfitting-Update-15_736x90";
        self.bannerVw.adSize = GADAdSizeFromCGSize(CGSizeMake(736, 90));
    }
    else if (screenSize.width== 1334)
    {
        self.bannerVw.adUnitID = @"/235389899/Clubfitting-Update-15_667x50";
        self.bannerVw.adSize = GADAdSizeFromCGSize(CGSizeMake(667, 50));
    }
    else if (screenSize.width== 1136)
    {
        self.bannerVw.adUnitID = @"/235389899/Clubfitting-Update-15_568x50";
        self.bannerVw.adSize = GADAdSizeFromCGSize(CGSizeMake(568, 50));
    }
    else if (screenSize.width== 960)
    {
        self.bannerVw.adUnitID = @"/235389899/Clubfitting-Update-15_480x50";
        self.bannerVw.adSize = GADAdSizeFromCGSize(CGSizeMake(480, 50));
    }
    else     //default
    {
        self.bannerVw.adUnitID = @"/235389899/Clubfitting-Update-15_736x90";
        self.bannerVw.adSize = GADAdSizeFromCGSize(CGSizeMake(736, 90));
    }

AdBanner Fragment code(To set and load banners):

self.bannerVw.rootViewController = self;

//I am currently using custom sizes and check smart anners also. 

//    self.bannerVw.adSize = kGADAdSizeSmartBannerLandscape;
    [self.bannerVw setDelegate:self];
    GADRequest *request = [GADRequest request];
//    request.testDevices = @[ GAD_SIMULATOR_ID ];
    [self.bannerVw loadRequest:request];

来源:https://stackoverflow.com/questions/28234564/google-dfp-creatives-randomly-display-although-correct-ad-tags-are-accessed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!