In my iOS application, i am integrate twitter login using fabric framework “TWTRComposer”. it is working fine when first time login and post t
The [Twitter sharedInstance]
object have two method to logout : logOut and logOutGuest.
Here is the link to the docs: Twitter object iOS reference
Just FYI you can check if the user is logged in using the session parameter like below
[[Twitter sharedInstance] session]
If session is nil then they are not logged in.
Try below thing if above thing not work, It might be possible cookies still exist.
NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (NSHTTPCookie *each in cookieStorage.cookies) {
// put a check here to clear cookie url which starts with twitter and then delete it
[cookieStorage deleteCookie:each];
}
[[Twitter sharedInstance] logOut]
and
[[Twitter sharedInstance] logOutGuest]
will not work, since as per the docs:
Deletes the local Twitter user session from this app. This will not remove the system Twitter account nor make a network request to invalidate the session.
So additionally, you need to invalidate the token returned by oauth. You can get help from twitter's docs. Use this REST webservice in order to invalidate token. Pass access_token
to the post request.
As per the link,
Allows a registered application to revoke an issued OAuth 2 Bearer Token by presenting its client credentials. Once a Bearer Token has been invalidated, new creation attempts will yield a different Bearer Token and usage of the invalidated token will no longer be allowed.
Hopefully it helps!
use this code:
[[Twitter sharedInstance] logOut];
Removing cookies - doesnt help.
I invent my own flow for relogin:
(I need user email to further login so only WebBasedLogin)
// Get first twitter acc (check if it exists etc...)
.....
// This method will be used if user the same
TWTRLoginMethod loginMethod = TWTRLoginMethodSystemAccounts;
// Check if it is the Previous twitter user (whom was stored in userDefaults)
if (![[STLUserDataManager lastTwitterUser] isEqualToString:[firstTwitterAccount username]])
{
// if user is new - ForceLogin
loginMethod = TWTRLoginMethodWebBasedForceLogin;
}
// inside completion
{
...
// Store userName in userDefaults
[STLUserDataManager storeTwitterUser:[firstTwitterAccount username]];
}