TwitterKit session store session returning nil incorrectly, then returning existing session when app is re-launched



I’m using TwitterKit in my iOS app. When the user first decides to login to Twitter, it checks for an existing session, using Twitter.sharedInstance().sessionStore.session(), and if no session is found then it logs them in using Twitter.sharedInstance().logIn(withMethods: TWTRLoginMethod.webBasedForceLogin).

On consecutive launches, it then checks for Twitter.sharedInstance().sessionStore.session() again to ensure the user is logged in, and calls the login function if not.

I’m seeing a weird behaviour though, and a beta tester has also reported it. Occasionally I’ll open the app, and Twitter.sharedInstance().sessionStore.session() will return nil, and so it’ll display the login form. Then if the login form is dismissed, and the app quit and re-opened, it again calls Twitter.sharedInstance().sessionStore.session() and this time finds the account they’re actually logged into, as expected.

I’ve tried to replicate this by opening the app with no connection and in other circumstances, and can’t find specific conditions under which it does this.

I’m wondering if this is a behaviour that’s expected for some reason, or if it’s an issue with TwitterKit?