FACEBOOK LOGIN In Unity [Easy INTEGRATION] !! 2023 (GAMING LOGIN, AUTHENTICATION, AND MORE !!)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys welcome back to coco3d in this video we will be implementing the Facebook login feature in our game so let's get started [Music] now this is an empty scene with main camera and the directional light so the step one is to download and import the Facebook SDK for that search for Facebook SDK for Unity and download the SDK now simply unzip it and import it into your Unity project now we can see that Facebook SDK is installed now click on Facebook edit settings and enter your app's name now it wants the Facebook app ID and the client token so let's open the developers.facebook.com here we can see all of our apps but we want to create a new app so click on create app now the Facebook provide us the two types of login First is the classic Facebook login and second is the gaming login so I will select the gaming login and if you like you can select the classic login it really doesn't matter because the rest of the implementation is almost the same now give your app a name email is fine and business account is optional so click on create app enter your password and submit so now our Facebook app is created and the first thing that we will do is to copy the app ID and paste it inside the unity right here then we want a client token and we can easily find it inside the app setting advance and here is the client token simply copy it and paste it right here now the last thing that we want is Android key store path and we can find it right here now simply copy it and paste it inside the Facebook settings right here now with that our setup is completed now let's create a UI like an image to show the profile picture and a text to show the player's name and a button to login into our account now let's create a game object which will do all of this work and name it as Facebook manager and also let's create a script for this game object and attach our script to that object now inside that script let's first get rid of this start and update and let's add some using statement for images text and Facebook like this and now let's create a text and an image field for our player name and the profile picture after that the first step is to initialize the Facebook SDK so let's create a region for that now create a awake function and inside it let's paste in this code now obviously it will take a lot of time to explain each individual line so you can just simply copy paste this code from the link in the description now as we can see we have to create two more functions so let's create the first wide set in it and inside this paste this code and now let's create the second function and under this function let's paste in this code and now we have to create one more function which is deal with FB menus which will display our players name and profile picture so let's create that so if we are logged in we are displaying this stuff and if we are not logged in we can just simply print that we are not logged in now as you can see to display the profile name and the profile picture we have to create two more function so let's quickly do that and with that our initialization is finally completed now obviously it is not the initialization it is doing a lot more stuff than that but it is better to put them all together like this so let's close this and now let's create two more function for Facebook log in and Facebook log out now for the Facebook login first we have to declare the permissions that we want like the profile pictures users friend Etc but in this video we will only be focusing on the profile picture so we will comment this user's friend and after that you can just simply login into the Facebook using the fp.login with read permissions just like this and as you can see it wants a auth callback function which is automatically called by the Facebook and will tell us that we are successfully logged in or not so let's create that function now if we are successfully logged in we are calling the set init which is basically displaying the user's profile picture and the name right here and if we are not logged in then we can just simply print that failed to login now with that our login is completed and now let's work on the logout function so for that we have to create an enumerator because logout can take some time and inside that animator let's paste in this code so we are just basically calling the FB dot logout but it can take some time so we are just waiting for that and after that we are just printing the log out successful and we are resetting our image and the profile picture so now let's simply call it from the logout function so now our login and the logout is completed and now let's create an extra region for some extra stuff like sharing to Facebook feed and it's callback and some other functions that can be useful for you but we are not implementing this thing in this video so let's simply close it and now let's link our UI element and also create a button for logout and simply link those button to their specific functions now let's build our project and check that it is working or not so let's click on Facebook login and as you can see it is throwing an error that the app is not accessible right now and the app developer is aware of this issue and you will be able to login into the app when the app is reactivated so yeah right now our app is on the testing phase that's why it is showing this error so let's open the Facebook dashboard and here you can see that we need to provide some details to Facebook in order to make our app live like the category the data deletion URL platform and things like that so let's quickly do that now in here fill in your privacy policy URL like this then click on category and select games now you can choose a subcategory I am choosing the strategy and you can also upload an icon if you want then click on Save changes now let's add the platform select Android then select Google Play click on next now here we have to enter our detail like key hash packet name and class name so open Unity Facebook edit settings so in here simply copy the key hash and paste it right here now let's copy the package name and paste it right here now the last thing is the class name so copy this entire line and paste it right here great so now everything is completed so let's click on go live and click this go live button and it want us to complete the data use checkup so let's click on start checkup and accept all these conditions foreign and now as you can see our checkup is completed so click on go live one more time and yes our app is now live now it can show you that the app not found if your app is not live on the Play Store now in my case my game is already live in the Play Store that's why this app has gone live but I remember that last time when my game was not live on the Play Store it asked me to First upload the game into the Play Store and when my game is publicly available for everyone then we should just press this go live button so now let's try to run our game one more time and as you can see it says that login error now if you face this problem all you have to do is just open your Google play Dashboard and under the app signing and here you can see the app sign in key certificate that is generated by Google for our app and other than that we can see the upload key certificates that is have been uploaded by us so all we have to do is just copy the sha1 certificate fingerprint that is generated by Google and open this website the link is in the description and paste here your sh1 certificate fingerprint and click on convert now copy this output and paste it inside your Facebook dashboard under the basic settings right here and click on Save changes now upload your game into the Google Play console under the internal testing and then try to run your game now this time if we press the Facebook login it is successfully showing me my profile and as we are using the gaming login we can change our profile pictures and our name so let me just select a new image and let me change my name now click on continue and here you can see that the name and the image is now successfully displayed so that's it guys this is the gaming login with Facebook and if you're trying to do the classic login so the only thing that you have to do is to provide your business verifications your you have to enter the data deletion URL that we have skipped in this step as it is not needed and I believe other than that all the steps are same but if you still find any problem in that you can just like comment it down below I will create a video on that too and that's it guys I hope you guys like this video If you guys like this video then do like this video And subscribe to coco3d and now I will see you in the next video bye [Music]
Info
Channel: Coco 3D
Views: 7,634
Rating: undefined out of 5
Keywords: unity, facebook, facebook login, facebook login in unity, facebook authentication
Id: xbTK77Vg6os
Channel Id: undefined
Length: 11min 41sec (701 seconds)
Published: Sun Sep 24 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.