I ran into an odd problem while integrating my game with Facebook SDK for Unity.
I am using latest Facebook SDK for Unity ( 3.1.2 ) and here is my code in a class I made:
public SocialConnect()
{
instance = this;
if ( ! IsInitCalled )
{
IsInitCalled = true;
FB.Init ( DoNothing , OnHideUnity );
}
}
public void Login()
{
if ( ! FB.IsLoggedIn )
{
FB.Login ("publish_actions", OnLogin );
}
}
private void DoNothing()
{
}
private void OnInitComplete()
{
IsInit = true;
if ( PlayerPrefs.GetInt("installed" , 0 ) == 0 )
{
PlayerPrefs.SetInt("installed" , 1 );
PlayerPrefs.Save();
FB.PublishInstall();
}
}
private void OnLogin()
{
}
private void OnHideUnity(bool isGameShown)
{
Debug.Log("Is game showing? " + isGameShown);
}
private void Callback( string response )
{
Debug.Log ("Facebook callback: " + response );
}
public static SocialConnect getInstance()
{
if ( instance == null )
{
instance = new SocialConnect();
}
return instance;
}
I call these methods from another scripts, for example:
if ( FB.IsLoggedIn )
// Display leaderboards here
}
else
{
SocialConnect.getInstance().Login();
}
After releasing the update, I am getting following issues:
1- When I run FB.login method, after clicking OK on the confirmation page on Facebook, it doesn’t grant me publish_actions permission so when FB.isloggedin varable will stay false and my app keep asking to Login again.
2- I got 2 different crashes in the last 24 hours with following for many users with following errors:
A.
Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=64206, result=0, data=null} to activity {com.facebook.unity.FBUnityPlayerActivity}:
B.
Caused by: java.lang.RuntimeException: Unable to resume activity {com.facebook.unity.FBUnityPlayerActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=64206, result=0, data=null} to activity
Thank you for your suggestions and help.