Hi guys i am working on a game with a Facebook login however i keep stuk on this error
Failed to Initialize the Facebook SDK
here is my code
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Facebook.Unity;
public class FBholder : MonoBehaviour {
void Awake ()
{
if (!FB.IsInitialized) {
// Initialize the Facebook SDK
FB.Init(InitCallback, OnHideUnity);
} else {
// Already initialized, signal an app activation App Event
FB.ActivateApp();
}
}
private void InitCallback ()
{
if (FB.IsInitialized) {
// Signal an app activation App Event
FB.ActivateApp();
// Continue with Facebook SDK
} else {
Debug.Log("Failed to Initialize the Facebook SDK");
}
FB.ActivateApp ();
var perms = new List<string>(){"public_profile", "email", "user_friends"};
FB.LogInWithReadPermissions(perms, AuthCallback);
}
private void OnHideUnity (bool isGameShown)
{
if (!isGameShown) {
// Pause the game - we will need to hide
Time.timeScale = 0;
} else {
// Resume the game - we're getting focus again
Time.timeScale = 1;
}
}
private void AuthCallback (ILoginResult result) {
if (FB.IsLoggedIn) {
// AccessToken class will have session details
var aToken = Facebook.Unity.AccessToken.CurrentAccessToken;
// Print current access token's User ID
Debug.Log(aToken.UserId);
// Print current access token's granted permissions
foreach (string perm in aToken.Permissions) {
Debug.Log(perm);
}
} else {
Debug.Log("User cancelled login");
}
}
}
i have added my app id in the Facebook settings in unity
i use this documentation https://developers.facebook.com/docs/unity/examples
Find FacebookGameObject.cs .. then replace this:
public void OnInitComplete(string message)
{
this.Facebook.OnInitComplete(message);
this.Initialized = true;
}
with this:
public void OnInitComplete(string message)
{
this.Initialized = true;
this.Facebook.OnInitComplete(message);
}
This mistake will be fixed in the next patch..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.