facebook / facebook-ios-sdk

Used to integrate the Facebook Platform with your iOS & tvOS apps.
https://developers.facebook.com/docs/ios
Other
7.73k stars 3.5k forks source link

iOS Facebook SDK lost session regularly #2372

Open yevgeniy-logachev opened 1 month ago

yevgeniy-logachev commented 1 month ago

Checklist before submitting a bug report

Xcode version

15.3

Facebook iOS SDK version

16.2.1

Dependency Manager

CocoaPods

SDK Framework

Login

Goals

We would like to solve issue with access token that Facebook sdk is handle. For almost the last 5 month we receive many complains from our users that application lost FB login regularly. It's like every day user open our app and see 'Login to Facebook' button despite he logged in yesterday. Some players say they may have same result even if they switch from game to iOS dashbors and return back. First complains we received at the end of December 2023 and it never happened before. Currently we have two different application with the same issue. Despite these two our application has different SDK (one uses Unity sdk, another iOS sdk) result the same.

Our investigation shows us that Facebook SDK return nil for 'currentAccessToken' variable of FBSDKAccessToken class when this happens. We've tried to update SDK to latest version but seems it isn't solution.

Expected results

currentAccessToken variable returns non-nil valid token and no need to login to application every day again

Actual results

Every day (sometimes even more frequent) users open application and see 'Login to Facebook' button again, despite they logged in recently.

Steps to reproduce

There is no specific steps to reproduce, you need simply login to FB, close it or move to background and return to game after a while.

Code samples & details

bool isLostFBSession = [FBSDKAccessToken currentAccessToken] == nil;
if (isLostFBSession) {
    PCLogInfo(kPCLogScopeApplication, @"FB session is lost");
}

// In the logs we see prints 'FB session is lost' when this issue happened
liproman commented 1 month ago

We're facing the same problem, but we've also figured out how to make it happen every time. Here's what's going on: When users install the new version of the app on top of the old one, they always have to log in to Facebook again when they open the app