Question by
nguyenhoai890 · Mar 11, 2018 at 04:55 PM ·
unity 5facebooklogin
FB.LogInWithPublishPermissions forces stop when there is no internet.
Hi guys,
Currently I'm implementing the facebook login for my game. It works well when a phone has internet. However, it seems facebook api does not cover the case that it can't connect to internet.
Currently, I don;t have any way to check if the facebook can connect to the internet or not, even the try catch does not trigger the catch but force closing the game.
Do you have any solution for my case?
Thanks,
My Code is ( We call LoginFaceBook function):
private void ExcuteFacebookFunction<T>(Func<T> actionsFunc)
{
try
{
if (IsFacebookInitialized())
{
actionsFunc();
}
else
{
FB.Init(() => {
if(FB.IsInitialized)
{
actionsFunc();
}
else
{
Debug.Log("Facebook is fail in INIT");
}
});
}
}
catch (Exception ex)
{
Debug.Log(ex.Message);
}
}
public void LoginFaceBook()
{
Debug.Log("LoginFaceBook _ Processing Facebook: " + IsProcessingLogin.ToString());
ExcuteFacebookFunction<object>(LoginFacebookCallBack);
}
private object LoginFacebookCallBack()
{
FB.ActivateApp();
var isLoggedIn = IsLoggedFacebook();
Debug.Log("isLoggedin: " + isLoggedIn.ToString());
if (!isLoggedIn.GetValueOrDefault(false))
{
Debug.Log("LogInWithPublishPermissions");
try
{
FB.LogInWithPublishPermissions(permissions, AuthFaceBookCallback);
}
catch (Exception ex)
{
//Can't trigger here. Just force closing the c
}
}
IsProcessingLogin = false;
Debug.Log("LoginFacebookCallBack _ Processing Facebook: " + IsProcessingLogin.ToString());
return null;
}
Comment