FbPlayableAd.onCTAClick() not found

Hello everyone.
I am trying to make a playable ad for facebook and I have two problems when testing with their playable preview:

1/ It does not recognizes the FbPlayableAd.onCTAClick() function despite it being in my project. I have this function that calls it:

function (event) { 
  if (typeof FbPlayableAd === 'undefined') {
    alert('FBPlayableAd.onCTAClick');
  }
    else {FbPlayableAd.onCTAClick();}
};

This is a code that suposedly only calls the function when Facebook has added its library and allows the game to run without error while in editor. But as it did not work, I also tried with just:

function (event) {
   FbPlayableAd.onCTAClick();
};

No dice either. So I’m at a loss as to what I can do right now.

2/ It keeps saying my file exceeds the 2Mo limit despite my zip being only 1Mo, and even unziped it only reachs 1.8Mo

Hi @Quentin and welcome,

Does the FB SDK requires some sort of initialization before you use it?

Also make sure that the library file comes first in your script loading order:

https://developer.playcanvas.com/en/user-manual/scripting/loading-order/

I am not sure about that, this is indeed strange. I’d say this is something to troubleshoot with their support.

  1. Regarding the FbPlayableAd you can check this StackOverflow answer.
  2. The 2 Mb limit is for the index.html. The zip archive has a limit of 5 Mb. If you add assets in base64 format inside index.html, it will grow. If you use zip, you can refer to the external assets in your zip file relative to the zip root. Refer to documentation.
2 Likes

I was able to find solutions (or at least causes) to my problems

1/ The game must be built without concatenating scripts (see in the build options) if you want facebook’s preview tool to detect the FbPlayableAd.onCTAClick() function

2/ Apparently, the preview tool just doesn’t work with zip files for detecting file size. Either make a single .html file for it (which I didn’t find a simple way of doing with placanvas) or try it out directly on a real facebook ad

2 Likes

Wait, what? That’s really odd :thinking:

Useful to know, thanks! (Seems like a PITA though :thinking:)