Facebook Application Setup
First, we need to create a Facebook application.
- Go to Facebook Developers website.
- Click Apps -> Create a New App , enter the name of your app and press Create App button.
- Choose Apps -> [your_app] and copy App ID and App Secret
Photon Dashboard Setup
- Open Photon Dashboard.
- Select the App Id that will be used and click See Details.
- Navigate to Authentication tab and uncheck Allow anonymous clients to connect, independently of configured providers.
- Select Facebook authentication provider and paste App ID and Secret.
- Check Reject all clients if not available.
- Open Unity.
- Setup PUN.
- Import Facebook SDK for Unity.
- In Unity's main menu go to Facebook -> Edit Settings, enter the App Name and App Id for your Facebook Application.
Create a new MonoBehaviour, attach it to an object on scene and then open. Use the following code for Facebook initialization and login:
To use Facebook Authentication in PUN, add:
The PUN callbacks for success and error that you can implement are:
In this tutorial we covered the basic steps required for integration of Facebook API with PUN.
Still have some questions? You are extremely welcome to ask it on forum. Happy coding!
To the top.