facebook-sdk-for-unity
facebook-sdk-for-unity copied to clipboard
16.0.1 FB SDK doesn't keep user logged in on subsequent sessions
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
- [X] I've updated to the latest released version of the SDK.
- [X] I've searched for existing GitHub issues
- [X] I've looked for existing answers on Stack Overflow, the Facebook Developer Community Forum and the Facebook Developers Group
- [x] I've read the Code of Conduct
- [x] This issue is not security related and can safely be disclosed publicly on GitHub
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 => { });
}
});
Only a problem with iOS as far as I can tell. The breaking commit was 7ba25ae91eb936b00826a63c8e0cd59158f68001
bump, we're also suffering the same problem
Same issue on iOS
after bump Facebook from 15.1.0
to 16.0.1
bump, we're experiencing same issue after update(
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
Same issue on iOS for Unity FB SDK 16.0.2
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.
- wait a second for FB.IsLoggedIn to become true.
- AccessToken.CurrentAccessToken is null now
- call FB.Mobile.RefreshCurrentAccessToken to get AccessToken