x


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.

more ▼

asked Oct 31 '11 at 07:50 PM

NiklasK gravatar image

NiklasK
16 2 3 4

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1999
x1956
x360
x87

asked: Oct 31 '11 at 07:50 PM

Seen: 1212 times

Last Updated: Oct 31 '11 at 07:50 PM