2
votes

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.

4

4 Answers

9
votes

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!

0
votes

As now (May 29, 2016) it is NOT FIXED. You must fix yourself with the code from JMilan, or others that made basically the same thing, just check the ResultDictionary before use it.

However, it has been submitted to be patched in the next release.

0
votes

This was fixed in 7.6.0 and verified to work now. https://developers.facebook.com/bugs/929096797187666/