facebook-sdk-for-unity icon indicating copy to clipboard operation
facebook-sdk-for-unity copied to clipboard

16.0.1 FB SDK doesn't keep user logged in on subsequent sessions

Open vnavarro opened this issue 1 year ago • 10 comments

Hi,

I've already opened it on a previous channel but was wrongly dismissed

https://developers.facebook.com/support/bugs/297755336112477/

So, I will give all info here.

Checklist

Environment

Unity Editor Version: 2021.3.25f1 Unity FB SDK 16.0.1 Builds: iOS and Android. Any version.

Goals

Use FB Login with a user-provided FB account so user will be logged in with FB in the game.

Expected Results

After the user logs in with Facebook login is not requested from the user until the token is expired, regardless of the game being closed.

Actual Results

The user logs in and has a valid non-expired access token with further away expiration in the future, when the game is closed and opened again FB SDK does not identify the user being logged in so it will ask the user for login again, no matter how many times it does never save it.

Steps to Reproduce

1 - Create Unity project and add FB SDK (16.0.1) to it (iOS/Android devices) 2 - Initialize Facebook SDK (FB.Init) and ask user to login FB.LogInWithReadPermissions use gaming_profile permission 3 - With the user successfully logged in close and kill the game 4 - Reopen the game, and check that after initializing facebook it still needs login (FB.IsInitialized = true and FB.IsLoggedIn = false)

Code Samples & Details

FB.Init(onInitComplete: () => {
  if (!FB.IsLoggedIn)
  {
    FB.LogInWithReadPermissions(FacebookSDKNeededPermissions, result => { });
  }
});

vnavarro avatar Aug 07 '23 08:08 vnavarro

Only a problem with iOS as far as I can tell. The breaking commit was 7ba25ae91eb936b00826a63c8e0cd59158f68001

mmunson-aftershock avatar Aug 09 '23 16:08 mmunson-aftershock

bump, we're also suffering the same problem

AvivWhalo avatar Aug 27 '23 08:08 AvivWhalo

Same issue on iOS after bump Facebook from 15.1.0 to 16.0.1

dreamcodestudio avatar Aug 30 '23 10:08 dreamcodestudio

bump, we're experiencing same issue after update(

MTPirate89 avatar Aug 30 '23 11:08 MTPirate89

You need to wait for the main thread after initializing the "FB.Init" Facebook sdk but if error still occur try refreshing current access token after confirming if user logged in FB.Mobile.RefreshCurrentAccessToken Hope this will help

AdeelAhmed60 avatar Mar 22 '24 11:03 AdeelAhmed60

Same issue on iOS for Unity FB SDK 16.0.2

lymancao avatar Apr 25 '24 01:04 lymancao

You need to wait for the main thread after initializing the "FB.Init" Facebook sdk but if error still occur try refreshing current access token after confirming if user logged in FB.Mobile.RefreshCurrentAccessToken Hope this will help

This is the right answer.

  1. wait a second for FB.IsLoggedIn to become true.
  2. AccessToken.CurrentAccessToken is null now
  3. call FB.Mobile.RefreshCurrentAccessToken to get AccessToken

lymancao avatar Apr 26 '24 09:04 lymancao