I use the following codes to initialize Facebook SDK (in OnGUI()):
if(GUI.Button(buttonRect, "Login")) {
if(!FB.IsInitialized) {
FB.Init(OnInitComplete, OnHideUnity);
} else {
OnInitComplete();
}
}
And its callback functions:
private void OnInitComplete() {
Debug.Log("FB.Init completed: Is user logged in? " + FB.IsLoggedIn);
Application.LoadLevel("NextScreen");
}
private void OnHideUnity(bool isGameShown) {
Debug.Log("Is game showing? " + isGameShown);
}
Then, I run the App in a real iPhone 5s with iOS 8.1.2, The log shows in Xcode 6:
FB.Init() has already been called. You only need to call this once and only once.
NullReferenceException: Facebook object is not yet loaded. Did you call FB.Init()?
at FB.get_FacebookImpl () [0x00000] in <filename unknown>:0
at FB.Init (Facebook.InitDelegate onInitComplete, System.String appId, Boolean cookie, Boolean logging, Boolean status, Boolean xfbml, Boolean frictionlessRequests, Facebook.HideUnityDelegate onHideUnity, System.String authResponse) [0x00000] in <filename unknown>:0
at FB.Init (Facebook.InitDelegate onInitComplete, Facebook.HideUnityDelegate onHideUnity, System.String authResponse) [0x00000] in <filename unknown>:0
at TitleScreen.StartGame () [0x00000] in <filename unknown>:0
at TitleScreen.Update () [0x00000] in <filename unknown>:0
(Filename: Line: -1)
FB.Init completed: Is user logged in? True
This issue does not happen in Android, or running within Unity. How can I resolve this?
p.s. This error does NOT forbid me from login to Facebook. Everything else is normal.
Referencing other similar questions (this and that), the case is different as the version is different (the Graph API versions used are different too)
Note: Using Unity 4.6.1, Facebook SDK for Unity 6.0.0