Sign In Register

How can we help you today?

Start a new topic
Answered

Facebook API Update

Hello,


I am new to GameSparks an i am a Beginner/intermediate level programmer. I am trying to integrate Facebook login into my game from the GameSparks Unity Tutorial. The example they give is out of date and a lot of the API is giving me errors in my code. Does anyone have an updated version of this example? I have attached a screen capture of the errors im getting.


https://docs.gamesparks.net/tutorials/unity-tutorials-challenges-part-2-facebook-login



1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

 

using UnityEngine;

using System.Collections;

using Facebook;

using GameSparks.Api.Requests;

 

public class LoginManager : MonoBehaviour

{

 

// Use this for initialization

void Start ()

{

//When the scene is ready we initialise Facebook

CallFBInit();

}

 

private void CallFBInit()

{

//When done initialising, call OnInitComplete

FB.Init(OnInitComplete, OnHideUnity);

}

 

 

private void OnInitComplete()

{

//Print to the debug log that we are initialised and check if we are logged in

Debug.Log("FB.Init completed: Is user logged in? " + FB.IsLoggedIn);

//Call FB.Login

CallFBLogin();

}

 

private void OnHideUnity(bool isGameShown)

{

Debug.Log("Is game showing? " + isGameShown);

}

 

private void CallFBLogin()

{

//We first tell Facebook what permissions we want and then tell it todo GameSparksLogin when done

FB.Login("email,user_friends", GameSparksLogin);

}

 

//FB.Login returns an FBResult, which is just information about our session

private void GameSparksLogin(FBResult fbResult)

{

//Check if we are logged in to Facebook

if (FB.IsLoggedIn)

{

//If so, we can use that acces token to log in to Facebook

new FacebookConnectRequest().SetAccessToken(FB.AccessToken).Send((response) =>

{

//If our response has errors we can check what went wrong

if (response.HasErrors)

{

Debug.Log("Something failed when connecting with Facebook " + response.Errors);

}

else

{

//Otherwise we are successfully logged in!

Debug.Log("Gamesparks Facebook Login Successful");

//Since we successfully logged in, we can get our account information.

UserManager.instance.UpdateInformation();

}

});

}

}

}

FB Errors.JPG
(77.1 KB)

Best Answer

Hi Joshua,


That tutorial is outdated, please refer to our new documentation tutorial which can be found here.


https://docs2.gamesparks.com/tutorials/game-engine-integrations/unity-facebook-sdk.html


-Pádraig

1 Comment

Answer

Hi Joshua,


That tutorial is outdated, please refer to our new documentation tutorial which can be found here.


https://docs2.gamesparks.com/tutorials/game-engine-integrations/unity-facebook-sdk.html


-Pádraig

Login to post a comment