简体   繁体   中英

Twitter Logout from browser not reflecting in app

I have used STTwitterAPI to login using either ACAccountStore or browser.

Here's a condition thats creating issue for me. When user logs in app using Twitter from browser(default safari), he gets call-backed to app and STTwitterAPI object stores the data.

Everything works fine. I can even tweet using that account. But if user switches to browser(default safari) and logs out from Twitter account(which he used while logging) and returns to app to tweet, it is done successfully with old account (associated earlier in browser before logging out), which should not be the case.

I want to ask the user again for logging in as he logged out from browser. I even tried using verifyCredentialsWithSuccessBlock:errorBlock : but it returns me user details of old user(the one logged out).

UPDATE:

App doesn't redirects user to browser after user is logged in. My concern is if user opens twitter in the browser out of volition, he is shown logged in to an account used while logging in(and that should be the case), but now user decides to either log out from that account or wishes to change account and logs out the account(used during login) from browser.

It gets logs out (which is fine) but when he returns to app, and try to tweet or do anything of twitter account, he should be asked for log in again. For that i used verify credentials. But the access token of previous login is still valid.

So, how to notify app that user has logged out of the browser or switched account. Is there any way to achieve. I'm stuck for at-least a week. Tried every alternative. None of them seems to work in my case. Any help would be appreciated. Thank You!!!

I haven't used the STTwitter framework much. But I can confidently say that TwitterKit by Fabric is much easier to use. I have used it for the scenario of SignUp and SignOut for Twitter in my app and it works flawlessly with the methods provided by it. You can check it out here:

https://dev.twitter.com/twitter-kit/ios/twitter-login

The syntax for login is like this:

[[Twitter sharedInstance] logInWithCompletion:^
            (TWTRSession *session, NSError *error) {
  if (session) {
      NSLog(@"signed in as %@", [session userName]);
  } else {
      NSLog(@"error: %@", [error localizedDescription]);
  }
}];

And for logout you have a – logOut method respectively.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM