I am working in an iOs environment using unity. Everything worked flawlessly with the Facebook API version 7.4 but since I got the new version the game breaks when Facebook initializes.
I get this error:
NullReferenceException: Object reference not set to an instance of an object
Facebook.Unity.FacebookBase.OnInitComplete (Facebook.Unity.ResultContainer resultContainer) (at Assets/FacebookSDK/SDK/Scripts/FacebookBase.cs:217)
Facebook.Unity.FacebookGameObject.OnInitComplete (System.String message) (at Assets/FacebookSDK/SDK/Scripts/FacebookGameObject.cs:62)
Facebook.Unity.Editor.EditorFacebook.Init (Facebook.Unity.HideUnityDelegate hideUnityDelegate, Facebook.Unity.InitDelegate onInitComplete) (at Assets/FacebookSDK/SDK/Scripts/PlatformEditor/EditorFacebook.cs:79)
Facebook.Unity.FB+<Init>c__AnonStorey38.<>m__4 () (at Assets/FacebookSDK/SDK/Scripts/FB.cs:234)
Facebook.Unity.FB+CompiledFacebookLoader.Start () (at Assets/FacebookSDK/SDK/Scripts/FB.cs:864)
I guess that is because I am calling the FB.API methods before it's initialized properly. However, I am not calling anything else, only FB.Init().
Thanks for the help.
We manage to fix it by editing FacebookBase.cs, around line 216 we add a check and do initialize the resultContainer.ResultDictionary dictionary.
+ if ( resultContainer.ResultDictionary == null )
+ {
+ resultContainer.ResultDictionary = new Dictionary< string, object >( 1 );
+ }
resultContainer.ResultDictionary[Constants.CallbackIdKey]
= this.CallbackManager.AddFacebookDelegate(loginCallback);
this.OnLoginComplete(resultContainer);
Hope it helps!