Hello,
I am using DFP to display Native ads in my application (v9.4.0 of the Play Services).
In my case, I have two scenarios that can happen when the ad has been clicked :
1. in some cases, I would like to handle the click myself
2. in others, I would like the SDK to redirect the user to the "Clickthrough URL"
Looking at the methods provided by the SDK, it doesn't seem possible at the moment : we can only always intercept clicks and handle them ourselves or always letting the SDK taking care of the click. There doesn't seem to be a middle ground.
From what I gathered, you have to know before loading your Ad (and your custom template) if you want to handle the click because that's the only moment you can attach a OnCustomClickListener:
AdLoader adLoader = new AdLoader.Builder(context, "/6499/example/native")
.forCustomTemplateAd("10063170",
new OnCustomTemplateAdLoadedListener() {
// Display the ad.
},
new OnCustomClickListener() {
@Override
public void onCustomClick(NativeCustomTemplateAd ad, String assetName) {
Log.i("MyApp", "A custom click just happened for " + assetName + "!");
}
}).build();
To resolve my case I would like to attach a OnCustomClickListener only after I received the TemplateAd and its custom information, most likely by setting it on the NativeCustomTemplateAd received.
Another way would be to be able in the CustomClickListener to fallback to the SDK if we don't want to handle the click anymore (for example by returning a boolean specifying whether we did handle the click or not).
Do you know of any way I could implement those functionnalities?
If not, I'm thinking about inserting a new field in my custom template repeating the "Clickthrough URL" in order to make the redirect by myself in the CustomClickListener... Do you have any counter-arguments on doing that?
Thanks