- Home /
Unity steals back focus when using Prime31 social plugin iOS
Hi,
I am trying to use the Prime31 social plugin for facebook integration.
The problems only occur when using the official facebook app. It this App is not installed, the plugin uses the browser for this without problems.
What happens when logging in using the
FacebookBinding.loginWithRequestedPermissions(new string[] { "publish_stream" } );
function, is that the facebook app tries to open the login page for a short period of time and then minimizes and opens the game again, returning a login failed. The login is never displayed and only shows the loading icon.
It seems like the game steals focus from the app before it can login properly and makes it fail.
Did anyone encounter this problem?
code to reporoduce:
/// <summary>
/// Submit to facebook depending on platform
/// </summary>
public void SubmitFacebook()
{
Debug.Log(FacebookBinding.isLoggedIn());
Application.runInBackground = true;
if(!FacebookBinding.isLoggedIn())
{
SocialNetworkingManager.facebookLogin += OnFacebookLogin;
SocialNetworkingManager.facebookLoginFailed += OnFacebookLoginFailed;
// Init our app
FacebookBinding.init("xxxxxxxxxxxxxxxx");
// login
FacebookBinding.loginWithRequestedPermissions(new string[] { "publish_stream" } );
}
else
{
PromtForPost();
}
}
/// <summary>
/// Returns a localized FB message
/// </summary>
/// <returns>
/// A <see cref="System.String"/>
/// </returns>
private string LocalizedFBMessage()
{
return string.Format(Localization.Instance.GetLocalizedPhrase("FACEBOOK_SHARE"),
StringUtils.ConvertToRaceTime( LevelModel.Instance.totalTime ),
LevelModel.Instance.costOfCrash);
}
/// <summary>
///When logged in to facebook, post message
/// </summary>
void OnFacebookLogin()
{
SocialNetworkingManager.facebookLogin -= facebookLogin;
SocialNetworkingManager.facebookLoginFailed -= facebookLoginFailed;
Debug.Log("Logged in");
PromtForPost();
}
/// <summary>
///Something failed
/// </summary>
/// <param name="error">
/// A <see cref="System.String"/>
/// </param>
void OnFacebookLoginFailed( string error )
{
SocialNetworkingManager.facebookLogin -= OnFacebookLogin;
SocialNetworkingManager.facebookLoginFailed -= OnFacebookLoginFailed;
Debug.Log( "Facebook login failed: " + error );
}
promtForPost is just a function to show a dialog where the user can select yes or no to post.
Your answer
Follow this Question
Related Questions
Specifying a high quality background image for iPad 1 Answer
How do I read XML on iOS? 2 Answers
Platform Dependent Compilation iOS vs iPhone 3 Answers
Does Unity iOS support GetPixels? 1 Answer