twitter-kit-ios
twitter-kit-ios copied to clipboard
Any trick to force persisting user session with `TWTRSessionStore`?
Since TwitterKit 3.2.1 (and in 3.3.0) user session is not persisted after the app is closed, so user has to repeat login procedure on each app launch. For some reason, this is not the case only if the app is opened in debug mode from Xcode.
I'm wondering if anyone found some workaround for this (within TwitterKit)?
I've tried to manually call saveSession:
upon successful login, but that didn't make a difference. Also reloadSessionStore
or sessionForUserID:
or just delaying the call to sessionStore
didn't help.
I guess it fails somewhere after unsafeLoadAllUserSessions
so authSessionCache
remains empty, but I don't have idea why.
Is this true? No persisting? Actually I am still using the previous, closed-source, version of TwitterKit. I've made my own client to replace TwitterKit, and the last thing I need to do is migrate existing tokens. So yeah it's not exactly related to this but chances are current TwitterKit session persistence is the same as in previous versions...
@zapjonny I think you should be fine with that version, this is regression in the last 2 (open source) versions.
Yes, it was sub-par so I never started using it. And now it's being deprecated, which is really the reason why I ended up here.
Anyway I figured out how to excavate existing TwitterKit oauth sessions using the method I described above. I just looked around in the open-sourced twitterkit session saving classes to figure out how to do it. Somehow persistence looks like it SHOULD work even with the newer opensource twitterkit lib, but I'll never now... and now I'm close to fully migrating away.
Here is what I did https://gist.github.com/jonnyijapan/8330876807be71a8237b26b5f13d70ad
I ended up implementing a temporary workaround for this issue which goes like this:
-
After the initial login with TwitterKit, manually save retreived session's
authToken
andauthTokenSecret
somewhere secure (ie. Keychain). Also, remember to clear this data when user logs out. -
Later on the next app start, manually pull out this data and if it exists use it to call
saveSessionWithAuthToken:authTokenSecret:completion
method onTWTRTwitter.sharedInstance().sessionStore
. In completion check if session is still valid (it should be) and then continue with loading user or whatever.
So until I implement a new "TwitterKit" for my app, I'm stuck with this. At least it's no longer necessary to login each time the app is opened... :)
my account has been suspended
I think the reason is a lot of Twitter, Twitter and follow-up
I would like to apologize to you
If you would give me another chance
Thank you