Facebook SDK script is missing

I imported the script into project, and apply it to the root entity
Then on another script in the initialize function, I copied this code from the official tutorial
app.on(“fb:init”, function () {
// use API
FB.login();
},

But I get this error in console , it says there is no script in the project

Link of my project is here : https://playcanvas.com/project/714999/overview/test

The issue is that the script file facebook-setup doesn’t contain a pc.ScriptType but has been added to an Entity.

Parse and remove FacebookSetup from your root Entity and the error/warning will go away.

The code in facebook-setup is in the global scope so it be execute when the script file is added to the HTML document.

1 Like

Thanks , now there is no such error

But after I call FB.login() function I get this :

That looks like an issue with your FB app setup. Try using the non iframe publish link. I’ve had issues with Auth systems and iframed before.

It’s working on a different profile, it’s weird
In the tutorial, I can’t figure out how to share the status with a predefined message
For example, i just need a simple thing like “My score is 10 , play our game: link”

Which tutorial? Facebook or ours? If ours, I wouldn’t be surprised if the API has changed as it was written a while ago.

It be worth looking at the FB documentation too.

I meant this tutorial: https://playcanvas.com/project/405897/overview/tutorial-facebook-api

I would look at FB documentation as that’s more likely to be up to date and have more examples too.