TwitterKit occasionally returning nil session for existing users

ios
fabric
twitterkit

#1

When a user opens my app, the login flow goes like this:

  1. Start TwitterKit with Twitter.sharedInstance().start(withConsumerKey: consumerKey, consumerSecret: consumerSecret).
  2. Start Fabric with Fabric.with([Crashlytics.self, Twitter.self]).
  3. Check for an existing session with Twitter.sharedInstance().sessionStore.session().
  4. If there is no existing session, allow them to login with Twitter.sharedInstance().logIn(withMethods: TWTRLoginMethod.webBasedForceLogin).

I’m seeing an intermittent problem where quite frequently, a user will open the app, after having previously logged in, and there won’t be an existing session - it’ll return nil, so they’re asked to login again. But then if they quit the app or cancel the new login, then start the app again, the existing session is returned as expected.


#2

Hey @AndrewProjDent,

That sounds like something very odd is happening. At any other point in your code base do you change or affect the sessionStore? If not, can you clarify how often this is happening? You mentioned intermittent and quite frequently, so is this is happening more often for a specific set of users (the same group over and over) to different people randomly? Do you have any other info on how/when this seems to be happening?

Would love to help track this down!

-Mike