floatinghotpot / cordova-plugin-facebookads

Cordova/PhoneGap plugin for Facebook Audience Network Ads
64 stars 71 forks source link

FacebookAds.setNativeAdClickArea not working #87

Open mowaiskalam opened 6 years ago

mowaiskalam commented 6 years ago

I am using Facebook Ads in my app but I am facing following issue:

Success function callback is firing properly when calling FacebookAds.setNativeAdClickArea but the click is not working. I have double checked all parameter (adId, x,y,w,h) is fine.

I am using Ad in Testing Mode

Can anyone facing the same issue? Please help me if anyone knows how to resolve it?

mowaiskalam commented 6 years ago

Is there anyone to reply? @floatinghotpot

jstncno commented 6 years ago

+1

jstncno commented 6 years ago

@mowaiskalam, and whoever else stumbles upon this, I've found that the coordinates for FacebookAds.setNativeAdClickArea are in pixels relative to the viewport. It works for me now, here is some of my code:

...
let x, y, w, h;
let viewportOffset = adElement.getBoundingClientRect();
w = adElement.clientWidth;
h = adElement.clientHeight;
x = adElement.offsetLeft;
y = viewportOffset.top;
FacebookAds.setNativeAdClickArea(adId, x, y, w, h);
...