mobile-sdk-ios icon indicating copy to clipboard operation
mobile-sdk-ios copied to clipboard

Fail to Fetch Ads

Open ScottCheckoSGI opened this issue 2 years ago • 4 comments

We are attempting to use Xandr Banner ads on both iOS 8.1.1 and Android 8.1. Both integrations are having similar issues where the server is returning errors. I'm providing some code snippets for context, but hopefully the main cause of the issue is indicated in the debug logs from AppNexus.

Before attempting to display banner ads, the SDK is initialized successfully. A callback is provided to init to verify there was a success in logs. We should have a valid memberID and placement ids, but we have little control over their configuration to verify. I have tried with preCacheRequestObjects enabled and disabled with no change.

void (^callback)(BOOL) = ^( BOOL success )
{
	if ( success ) {
		std::cout << "XandrBridge::Initialize -- sdk successfully initialized" << std::endl;
	} else {
		std::cout << "XandrBridge::Initialize -- failed to initialize sdk." << std::end;
        }
};

[ANLogManager setANLogLevel:ANLogLevelDebug];
[ANGDPRSettings setConsentRequired:[NSNumber numberWithBool:gdprApplies]];
[ANGDPRSettings setConsentString:[NSString stringWithUTF8String:consentString.c_str()]];
[[XandrAd sharedInstance] initWithMemberID:memberId preCacheRequestObjects:true completionHandler:callback];

The banner being created is a vanilla non-native, non-lazy ANBannerAdView. I have also tried a variation of this with lazy load enabled, with no change in the error either.

const auto frame = CGRectMake( 0.f, 0.f, size.width, size.height );
self.banner = [ANBannerAdView adViewWithFrame:frame placementId:placementId adSize:size];
auto* controller = GetRootViewController();
self.banner.rootViewController = controller;
self.banner.delegate = self;
self.banner.autoRefreshInterval = 0;
[controller.view addSubview:self.banner];
[self.banner loadAd];

Since initialize looks like its working, we assume that the memberId is correct? However, when requesting banner ads it seems like that is not the case judging from the errors?

2022-11-09 15:49:22.805832-0800 App[22955:24922451]  APPNEXUS DEBUG  -[ANBannerAdView autoRefreshInterval] -- autoRefreshInterval returned 0.000000 seconds
2022-11-09 15:49:22.806884-0800 App[22955:24922451]  APPNEXUS DEBUG  -[ANAdFetcherBase requestAd]_block_invoke -- Response JSON (for single tag requests ONLY)... {"error":"Could not find valid member in request"}
2022-11-09 15:49:22.807277-0800 App[22955:24922451]  APPNEXUS DEBUG  +[ANUniversalTagAdServerResponse generateTagsFromResponseData:] -- jsonResponse={
    error = "Could not find valid member in request";
}
2022-11-09 15:49:22.807539-0800 App[22955:24922451]  APPNEXUS ERROR  +[ANUniversalTagAdServerResponse generateTagsFromResponseData:] -- FAILED to find an array of tags in UT Reponse data.
2022-11-09 15:49:22.807776-0800 App[22955:24922451]  APPNEXUS ERROR  -[ANAdFetcherBase prepareForWaterfallWithAdServerResponseTag:] -- tag is nil.
2022-11-09 15:49:22.808075-0800 App[22955:24922451]  APPNEXUS DEBUG  -[ANBannerAdView autoRefreshInterval] -- autoRefreshInterval returned 0.000000 seconds
2022-11-09 15:49:22.808353-0800 App[22955:24922451]  APPNEXUS INFO  -[ANAdFetcher finishRequestWithError:andAdResponseInfo:] -- No ad received. Error: The server responded, but didn't return any ads.
[ 244.456] XandrAdViewDelegate -- Xandr ad failed to load with error code: 2 and description: The server responded, but didn't return any ads.
2022-11-09 15:49:22.808640-0800 App[22955:24922451] [ 244.456] XandrAdViewDelegate -- Xandr ad failed to load with error code: 2 and description: The server responded, but didn't return any ads.

Presumably, the memberId is incorrect? uninitialized? And the server is rejecting the request, causing the client to fail to parse the response? If SDK initialization is completed successfully how could this be possible? I attempted to discern the purpose of the "tags" referenced in some of the errors from source, but didn't see anything revealing.

Is the memberId supposed to be set on the banner ad so that the request picks it up? I found the method [ANAdProtocolFoundation setInventoryCode] that I assume sets both the inventory code and memberId at the banner level, but the inventoryCode is not available to us. I tried with a dummy value so that at least the memberId could be set with no luck. The memberId property is otherwise readonly on banners. Is the inventoryCode mandatory to set the memberId even with a placementId?

Interstitial ads have the same issue, including both banner and interstitials on Android.

Any advice on how to proceed would be appreciated. Let me know if any more information is required.

ScottCheckoSGI avatar Nov 17 '22 19:11 ScottCheckoSGI

Hi @ScottCheckoSGI ,

Similar to the comment I made in Android, you are intending to use inventory code, but using placement id API's. Placement Id is always a number. (and is autogenerated) Inventory code is Alphanumeric string. (chosen/set by your AdOps team)

Can you try using: self.banner = ANBannerAdView(frame: CGRect, memberId: <#T##Int#>, inventoryCode: <#T##String#>, adSize: <#T##CGSize#>)

Kowshickkarthick avatar Nov 17 '22 21:11 Kowshickkarthick

Thank you, this makes a lot of sense. I will start testing this hopefully later today.

ScottCheckoSGI avatar Nov 17 '22 22:11 ScottCheckoSGI

Hello @Kowshickkarthick,

Using the memberId/inventoryCode version, it looks like there aren't anymore parsing errors so this is progress. There is a warning/error "No ad received. Error: The server responded, but didn't return any ads" still showing up though. Does this lead to likely being a configuration issue at this point, to be raised with our ad ops?

I have tried using the placement id for both interstitials and banner ads from the example app, and both work fine.

This is some of the logs from the server response using the real ids. It looks like nobid=1 indicates that there just isn't any fill right now?

2022-11-18 18:22:53.740567-0800 App[16149]  APPNEXUS DEBUG  +[ANUniversalTagAdServerResponse generateTagsFromResponseData:] -- jsonResponse={
    tags =     (
                {
            "ad_profile_id" = XXXXX;
            "auction_id" = XXXXXXXXXXXXXXXXXXX;
            nobid = 1;
            "tag_id" = XXXXX;
            uuid = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
        }
    );
    version = "3.0.0";
}
2022-11-18 18:22:53.740629-0800 App[16149]  APPNEXUS WARNING  -[ANAdFetcherBase prepareForWaterfallWithAdServerResponseTag:] -- The server responded, but didn't return any ads.
2022-11-18 18:22:53.742274-0800 App[16149]  APPNEXUS INFO  -[ANAdFetcher finishRequestWithError:andAdResponseInfo:] -- No ad received. Error: The server responded, but didn't return any ads.
2022-11-18 18:22:53.743609-0800 App[16149]  APPNEXUS DEBUG  -[ANAdView setAdResponseInfo:] -- Setting adResponseInfo to <ANAdResponseInfo: 0x283d20000>

Let me know if any more information is needed. Thank you for the help.

ScottCheckoSGI avatar Nov 19 '22 02:11 ScottCheckoSGI

HI @ScottCheckoSGI, You are right. nobid=1 means there was no ad returned for this auction.

If its just for testing your integration like to test various sizes, ad rendering etc you can ask you adops team to setup some "Managed inventory" so that you can test your setup.

Kowshickkarthick avatar Nov 21 '22 16:11 Kowshickkarthick