0
votes

When calling FB.Login from the unity facebook plugin (I've tried 4.2.4 and 4.3.3) from within a canvas facebook web app, the callback function is never called when the user hits Cancel when prompted by the facebook dialog to accept the permissions of the app.

Init works fine, the sdk loads, then I call FB.Login with a facebook delegate and if the user cancels, there is no callback. You can see this behavior in the example provided in the sdk if you build it as a webapp and create a canvas app in facebook that points to it.

Any suggestions? I need that callback to continue the flow of my application.

Thank you.

1
Thanks for the report, we are looking into this.benp

1 Answers

1
votes

This issue is caused by the fact that AbstractFacebook simply ignores the entire FBResult argument received from Facebook API, including the "cancelled" parameter when user refuses to grant access privileges to the app.

Decompiled OnAuthResponse method from AbstractFacebook looks like:

protected void OnAuthResponse(FBResult result)
{
    Dictionary<string, object> dictionary = new Dictionary<string, object>();
    dictionary["is_logged_in"] = (object) (bool) (this.IsLoggedIn ? 1 : 0);
    dictionary["user_id"] = (object) this.UserId;
    dictionary["access_token"] = (object) this.AccessToken;
    dictionary["access_token_expires_at"] = (object) this.AccessTokenExpiresAt;

    FBResult result1 = new FBResult(Json.Serialize((object) dictionary), result.Error);
    using (List<FacebookDelegate>.Enumerator enumerator = this.authDelegates.GetEnumerator())
    {
        while (enumerator.MoveNext())
        {
            FacebookDelegate current = enumerator.Current;
            if (current != null)
            current(result1);
        }
    }
    this.authDelegates.Clear();
}

If you could override this behavior somehow, maybe you could strip the "cancelled" parameter form JSON stored in result.message.