Facebook SDK 7.2.1 Unity Login Crash on device iOS9, not in editor
Everything is working perfectly inside unity editor, but when I build for iOS and test on device I get this error everytime I try to login to facebook:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'can't start iterating in the middle of an iteration'
Here's the code I'm using inside Unity:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using Facebook.Unity;
public class NewFbLogin : MonoBehaviour
{
public Button fbLoginBtn;
public void FbLogin()
{
var perms = new List<string>(){"public_profile", "email", "user_friends"};
FB.LogInWithReadPermissions(perms, AuthCallback);
}
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);
}
fbLoginBtn.gameObject.SetActive(false);
} else {
Debug.Log("User cancelled login");
}
}
}
Am I missing something?
Thanks for your help!
I have another script that uses iAd banner, I disabled that script and everything is working fine, however I don't want to disable iAds... :/
@mrgeorge3d It sounds like this issue is not related to the Facebook SD$$anonymous$$ for Unity. For posterity though, please keep us informed on how work around this.
This is what is happening on iOS9 Device:
I have a Login button inside a Scene, and also Im Displaying an iAd as mentioned in the docs in the same scene
The iAd Displays properly inside my scene.
I click my Facebook login button and it opens the new iOS9 login Safari screen.
I click Ok to accept the requested perms.
The App crashes with the error I mentioned before.
I've already tested this with an older device (iOS8) and facebook works fine!
The problem is inside iOS 9... So I don't $$anonymous$$now if this is a facebook issue or an iAd Banner issue, cause if I Disable the script that displays the banner, I can login to facebook without any problem.
Thanks @zzzzzz789
Answer by LTX · Jan 30, 2016 at 01:46 AM
This is what i have figured.
http://answers.unity3d.com/questions/1077864/facebook-sdk-710-integration-crash.html#answer-1081165
Answer by matbrummitt · Nov 06, 2015 at 08:17 AM
My app crashes when pressing my login button, i don't see any Facebook pages it just closes immediately. Not running iAds just unity ads