Since two days i m working to build Facebook SDK that would work with Unity Standalone Builds. Here is progress :- 1) Works well with Standalone Builds (Windows,MAC & Linux) [Completed] 2) Also Works with Webplayer Builds. [Working But Some Fixes Needed] But here i m finding a way to Open Login URL in new Tab. Currently its being blocked by “Popup Blocker”. 3) Failed to Work with WebGL [Further Work is Needed] Here WWW is not working. You can check the Webplayer Build Here. Make sure you allow popups for this Link. After Login it will show your Facebook Name & will Load your profile picture.
The only solution i found is to put HTML based Login Button. That button can be created manually or by patching html code via ExternalEval. That login button can be “<a href” or javascript “OnClick” which won’t be blocked by Browser popup Blockers.
Login Button, i mean “Opening a link in new tab/popup” is the most tricky part in Web Builds. I didn’t get any good solutions for now. So i m using the SDK for Standalone builds only (Window,Mac and Linux).
For some reason when i compile a stand alone player no connect popup appears. Reading the facebook site it says the SDK doesnt support unity standalone builds : / Do you have a link to the sdk you are using?
I have created that SDK myself. I m requesting https://graph.facebook.com/ using Unity’s WWW. And so it is possible to implement almost all features given by official FB SDK, as internally they use the same. But the login process is quite different. We have to redirect the user to FB login page via some web browser (or Webview!!).
Hello RJproz, That sounds great! I’d love to see how you got this working.
As I have been trying a few things myself, but could not get the system to work (in standalone).
Ps. Maybe you can share/sell your code on the asset store?
You need a server (PHP or any other) to get the access token of login process. I have also tested it by creating custom server using TcpListener. The choice would be yours.
And yes, the main part is just the login process, which is quite different from what we see in Official SDK. The rest, is just simple WWW and WWWForm.
Thank You for reacting so quickly!
The link does not work unfortunately.
It sounds like an interesting method you have there.
I would love to learn more about it.
As of yesterday, the Facebook Login is still popup-blocked in WebGL (using chrome). Browsers typically do this because the popup was triggered programatically, and not from within a javascript click event.
Unless the wizards at facebook can figure something out, in order to avoid the popup blocker you will probably have to implement your own web / javascript based facebook login flow, and integrate that using this feature that unity provides: http://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html
One exception I have noticed, is that the Facebook SDK in WebGL will actually work properly (no popup blocker problems) if it’s running as a Facebook Canvas game (loaded within facebook). I think this is because it must access the FB javascript SDK within facebook, skips the oauth/login, and goes straight to permissions (which is displayed as a modal within the facebook canvas).
So I think i’ll have to do something special (ala link above) when the WebGL game is not running within the facebook canvas.
@philwinkel
I think i got a solution.
Webplayer is now deprecated. So, yes WEGL is also my main focus to deploy my games for Web Platform.
WebGL build also creates a index html file. But here when we submit the Webgl build (to Web Portals or our own), we need to submit the zip. That means the index file will also be there. So we can modify the html file and add login button using ‘href’. And then we can link the logic between browser and unity as given in the link you gave.
I see u got Facebook working on Standalone. I am currently struggling to get the access token as I am not very good with server side scripting so I was wondering whether you could help me out a little
I see the importance of the project but i m too lazy to create a Asset store package for it. So, i have uploaded the project in BitBucket. Let’s just keep it free. (No selling please )