[英]Failed to Initialize the Facebook SDK Unity5.2 Facebook SDK 7
嗨,大家好,我正在使用Facebook登錄進行游戲,但是我一直在處理此錯誤
初始化Facebook SDK失敗
這是我的代碼
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");
}
}
}
我已經在Facebook設置中統一添加了我的應用ID
找到FacebookGameObject.cs ..然后替換為:
public void OnInitComplete(string message)
{
this.Facebook.OnInitComplete(message);
this.Initialized = true;
}
有了這個:
public void OnInitComplete(string message)
{
this.Initialized = true;
this.Facebook.OnInitComplete(message);
}
該錯誤將在下一個補丁中修復。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.