Facebook SDK v7.2 login not working when on android

Hello,
so here is my problem.
I am using tthe newest Unity and Facebook SDk. What I want to do is have a facebook login on the menu screen of my game and a share button if the player is logged in.

I got it all to work just fine in the editor, the login with the token and share work like they should (I think)
But when I bulild the app and put it on android, the game works fine, but when I click my login button, the Facebook window pops up like it should but it says “Error, you are not logged in”

Um… well yeah, I am not logged in since I just pressed the login button. I cant figure this one out.
Did anyone have a similar problem with the new SDK?
If not I will post my code of my login and shar scripts and would apreciate any help :slight_smile:

Thank you!

It sounds like you might be trying to share before you’re logged in (i.e. an issue with your logic). If you post the code you use to decide what action to take when the button is pressed it will help find the problem.

phill_me_up I dont know why but I couldnt reply to your anwser so my reply is here.

Nope, that is not it, I always check if its logged in before doing anything. Also thie error apears when I click the button that only does the login and no sharing. But thank you for your reply.

I will add my code here. Please take a look and I am sorry if it’s just a noobish mistake I missed.
This code is what I put together from the examples thata are on the Facebook developers website.

using UnityEngine;
using System.Collections;
using Facebook.Unity;
using System.Collections.Generic;

public class FBscript : MonoBehaviour {

    // Include Facebook namespace
    public GameObject fbButton; // Assign in inspector

    // Awake function from Unity's MonoBehavior
    void Awake()
{
    if (!FB.IsInitialized)
    {
        // Initialize the Facebook SDK
        FB.Init(InitCallback, OnHideUnity);
    }
    else
    {
        // Already initialized, signal an app activation App Event
        FB.ActivateApp();
    }

        
    
}

     void Start() {
         if (FB.IsLoggedIn)
         {
             fbButton.SetActive(false);
         }
         else
         {
         fbButton.SetActive(true);

         }


     }

    private void InitCallback()
{
    if (FB.IsInitialized)
    {
        // Signal an app activation App Event
        FB.ActivateApp();
        // Continue with Facebook SDK
        // ...
    }
    else
    {
        Debug.Log("Failed to Initialize the Facebook SDK");
    }
}

private void OnHideUnity(bool isGameShown)
{
    if (!isGameShown)
    {
        // Pause the game - we will need to hide
        Time.timeScale = 0;
    }
    else
    {
        // Resume the game - we're getting focus again
        Time.timeScale = 1;
    }
}
    public void loginFunction()
    {
        if (FB.IsLoggedIn)
        {
            Debug.Log("User already logged in!");
        }
        else
        {
          
            var perms = new List<string>() { "public_profile", "email", "user_friends" };
            FB.LogInWithReadPermissions(perms, AuthCallback);
            
        }
    }

private void AuthCallback(ILoginResult result)
    {
        if (FB.IsLoggedIn)
        {
            // AccessToken class will have session details
            var aToken = Facebook.Unity.AccessToken.CurrentAccessToken;
            // Print current access token's User ID
            Debug.Log(aToken.UserId);
            // Print current access token's granted permissions
            foreach (string perm in aToken.Permissions)
            {
                Debug.Log(perm);
            }
            fbButton.SetActive(false);

        }
        else
        {
            fbButton.SetActive(true);
            Debug.Log("User cancelled login");
        }
    }

}

I have a button on the scene that runs the public function loginFunction()
And that is all I can say about it… I dont understand what goes wrong after that.