Search Unity

FacebookSDK and WebGL

Discussion in 'Web' started by nsmith1024, Jul 23, 2019.

  1. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    Hello,

    Does anybody know how to use the facebook SDK with WebGL?

    I imported the FaceBook SDK, created App ID, and then did a WebGL build, and uploaded the WebGL build to my personal web server like i always do.

    I load it up in the browser, and it calls FB.Init(...) but it never returns from that, and there are no errors or messages given in the browsers developers console.

    Does anybody know what's going on? Maybe i have to host it on facebook's server, or maybe something else I have to do?

    Does anybody know?

    Thanks
     
  2. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    Try hosting it on the FB hosting service. That has been working quite well in our testing in the past.
    Do FB's SDK example scenes work from your hosting?
     
  3. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    I havnt tried their sample scene while hosting it from my server, I will try that.

    I have complicated PHP scripts and a mysql database running on my server for the game, also stores a lot of other files needed by the game on the server too like scene bundles, images etc. How would that all work if I use Facebooks server?
     
  4. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    You can setup your game in a way, that is requests and gets all the stuff from your server even if some of it is hosted on FB I suppose.
     
  5. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    I wonder if facebook would allow the core game code to be hosted on their server, while the running game code is accessing another server to get data as you suggest. Are they really picky? They may talk about CORS, and security, hacking and what not, then deny my game to go public on their server because of that?

    But i have no choice but to try anyway.
     
  6. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    I would assume they are open to that but have not dealt with them personally in that capacity.
     
  7. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    I downloaded the unity edition 2018.1 for facebook, did a build using only the facebook demo scene s that came with the SDK. Everything built without errors.

    The instructions on facebook...

    https://developers.facebook.com/docs/games/gamesonfacebook/unitywebgl/#upload

    ...said there would be a .7Z file produced after the build was completed, but there is no such file, only the regular Build,StreamingAssets,TemplateData and index.html from a regular WebGL build.

    Maybe this 7Z file is only made when using a later version of Unity? I have to use 2018.1

    Do I just zip up those files/folders into a .7Z and upload that to facebook?
     
  8. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    1,073
    If you build it with the editor FB platform support you can upload it from there. otherwise just throwing it into a 7z and uploading manually might work too.
     
  9. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    870
    Its so confusing, If i make a zip file and upload it manually on the facebook upload page, it gives an error about facebook CDN not being referenced, but if i upload it using Unity, there is no error, but when i go to facebook the upload is not there LOL. When i try to access the URL it gives me to run the game (even though i dont see the game upload anywhere) it says i cant run it because there is no production version. Guess im doing something wrong.

    The tutorial on facebook dont match whats actually happenning, there is no option to "push to production" from unity as mentioned in the tutorial. Besides i just want to test it, im just using the facebook SDK demo now, my code is not in there anywhere. Manual uploads dont work,and the upload from unity dont show up on the developer page.

    I sure it will be cool if i get it to work though!
     
    Last edited: Jul 30, 2019