facebook / facebook/facebook-ios-sdk
iOS Facebook SDK lost session regularly
- Dominant language
- Swift
- Stars
- 8.1k
- Forks
- 3.7k
- PR merge metrics
- No merged PRs in 30d
Description
### Checklist before submitting a bug report
- [X] I've updated to the latest released version of the SDK
- [X] I've searched for existing [GitHub issues](https://github.com/facebook/facebook-ios-sdk/issues)
- [X] I've looked for existing answers on [Stack Overflow](https://facebook.stackoverflow.com), the [Facebook Developer Community Forum](https://developers.facebook.com/community/) and the [Facebook Developers Group](https://www.facebook.com/groups/fbdevelopers)
- [X] I've read the [Code of Conduct](https://github.com/facebook/facebook-ios-sdk/blob/main/CODE_OF_CONDUCT.md)
- [X] This issue is not security related and can safely be disclosed publicly on GitHub
### 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
```swift
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
```
Contributor guide
Assessment
This issue has not been assessed yet.