Twitter / Fabric登录按钮只能工作一次

时间:2021-01-20 15:22:17

I'm using, with success the Fabric Login button (TWTRLogInButton, https://dev.twitter.com/twitter-kit/ios-reference/twtrloginbutton).

我正在使用Fabric Login按钮(TWTRLogInButton,https://dev.twitter.com/twitter-kit/ios-reference/twtrloginbutton)。

In my Swift app I can authenticate myself, make calls and all. The only problem is that i've implemented a "Logout" button that calls Twitter.logOut().

在我的Swift应用程序中,我可以验证自己,打电话和所有。唯一的问题是我已经实现了一个调用Twitter.logOut()的“Logout”按钮。

As specified by the documentation (https://dev.twitter.com/twitter-kit/ios-reference/twitter) this deletes the local session but does not invalidate the remote session. The effect is that once I'm authenticated and then logged out, if I click the "Login" button again I'm logged-in again with the same user, effectively preventing me from switching user.

根据文档(https://dev.twitter.com/twitter-kit/ios-reference/twitter)的规定,这将删除本地会话,但不会使远程会话无效。结果是,一旦我通过身份验证然后退出,如果再次单击“登录”按钮,我将再次使用同一用户登录,从而有效地阻止我切换用户。

Any help?

有帮助吗?

4 个解决方案

#1


2  

The logOut is a class method, did you call:

logOut是一个类方法,你打电话给:

 Twitter.sharedInstance().logOut()

#2


2  

The incomplete logout issue you guys are facing is actually more related to iOS persisting system accounts. TwitterKit automatically logs a user in if they were already logged in on iOS. You can workaround this behavioral in the use case of kiosk with these steps:

你们面临的不完整的注销问题实际上与iOS持久系统帐户有关。如果用户已经登录iOS,TwitterKit会自动将用户登录。您可以使用以下步骤在kiosk的用例中解决此行为:

  1. Login to Twitter in Settings > Twitter
  2. 在“设置”>“Twitter”中登录Twitter
  3. Switch to your app and attempt to login with Twitter
  4. 切换到您的应用程序并尝试使用Twitter登录
  5. Disallow access to Twitter accounts when the grant access dialog comes up:
  6. 当授权访问对话框出现时,禁止访问Twitter帐户:

Twitter / Fabric登录按钮只能工作一次

This prevents TwitterKit from accessing your system accounts and every user will have to login. Hope this helps!

这可以防止TwitterKit访问您的系统帐户,并且每个用户都必须登录。希望这可以帮助!

(Initially Twitter.sharedInstance().logOut() destroys local session...)

(最初是Twitter.sharedInstance()。logOut()会破坏本地会话...)

#3


2  

use method

使用方法

[[Twitter sharedInstance] logInWithMethods:TWTRLoginMethodWebBasedForceLogin completion:{}]

Parameter TWTRLoginMethodWebBasedForceLogin

参数TWTRLoginMethodWebBasedForceLogin

  • Presents a web view that doesn't use any cached sessions from Safari. Allows the developer to provide multi-user functionality with several Twitter accounts.
  • 提供不使用Safari中任何缓存会话的Web视图。允许开发人员使用多个Twitter帐户提供多用户功能。

#4


1  

I came across this problem as well, but it seems that this is how it behaves, Twitter "saves" the credentials on an OS level using Accounts framework. You can see this here:

我也遇到了这个问题,但似乎这就是它的行为方式,Twitter使用Accounts框架“保存”操作系统级别的凭据。你可以在这里看到:

go to Settings on your phone -> Twitter and you'll see the account there go into the account and "Delete Account"

转到您手机上的设置 - > Twitter,您会看到该帐户进入该帐户并“删除帐户”

once you delete the account you will find that when you launch your app and try to login to twitter now you will be asked to sign in.

删除帐户后,您会发现当您启动应用并尝试登录Twitter时,系统会要求您登录。

Once an account is added there is no way to take out the account, (unless Twitter supports this and makes it public) The User will have to manually go into Settings -> Twitter and delete the account from there to be able to sign in to a different account.

一旦添加了帐户,就无法取出帐户,(除非Twitter支持并将其公开)用户必须手动进入设置 - > Twitter并从那里删除帐户才能登录一个不同的帐户。

Also i noticed that when you add another account into Twitter, trying to login you will be given a chance to login either account when using [[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error)

另外我注意到当你在Twitter中添加另一个帐户时,尝试登录时你将有机会在使用[[Twitter sharedInstance] logInWithCompletion时登录任一帐户:^(TWTRSession * session,NSError * error)

edit: Upon further Research if the User allows the app to use "Twitter" accounts you are able to access the Accounts Framework and delete the account from there:

编辑:进一步研究如果用户允许应用程序使用“Twitter”帐户,您可以访问帐户框架并从那里删除帐户:

https://developer.apple.com/library/mac/documentation/Accounts/Reference/ACAccountStoreClassRef/index.html

https://developer.apple.com/library/mac/documentation/Accounts/Reference/ACAccountStoreClassRef/index.html

Cheers!

干杯!

#1


2  

The logOut is a class method, did you call:

logOut是一个类方法,你打电话给:

 Twitter.sharedInstance().logOut()

#2


2  

The incomplete logout issue you guys are facing is actually more related to iOS persisting system accounts. TwitterKit automatically logs a user in if they were already logged in on iOS. You can workaround this behavioral in the use case of kiosk with these steps:

你们面临的不完整的注销问题实际上与iOS持久系统帐户有关。如果用户已经登录iOS,TwitterKit会自动将用户登录。您可以使用以下步骤在kiosk的用例中解决此行为:

  1. Login to Twitter in Settings > Twitter
  2. 在“设置”>“Twitter”中登录Twitter
  3. Switch to your app and attempt to login with Twitter
  4. 切换到您的应用程序并尝试使用Twitter登录
  5. Disallow access to Twitter accounts when the grant access dialog comes up:
  6. 当授权访问对话框出现时,禁止访问Twitter帐户:

Twitter / Fabric登录按钮只能工作一次

This prevents TwitterKit from accessing your system accounts and every user will have to login. Hope this helps!

这可以防止TwitterKit访问您的系统帐户,并且每个用户都必须登录。希望这可以帮助!

(Initially Twitter.sharedInstance().logOut() destroys local session...)

(最初是Twitter.sharedInstance()。logOut()会破坏本地会话...)

#3


2  

use method

使用方法

[[Twitter sharedInstance] logInWithMethods:TWTRLoginMethodWebBasedForceLogin completion:{}]

Parameter TWTRLoginMethodWebBasedForceLogin

参数TWTRLoginMethodWebBasedForceLogin

  • Presents a web view that doesn't use any cached sessions from Safari. Allows the developer to provide multi-user functionality with several Twitter accounts.
  • 提供不使用Safari中任何缓存会话的Web视图。允许开发人员使用多个Twitter帐户提供多用户功能。

#4


1  

I came across this problem as well, but it seems that this is how it behaves, Twitter "saves" the credentials on an OS level using Accounts framework. You can see this here:

我也遇到了这个问题,但似乎这就是它的行为方式,Twitter使用Accounts框架“保存”操作系统级别的凭据。你可以在这里看到:

go to Settings on your phone -> Twitter and you'll see the account there go into the account and "Delete Account"

转到您手机上的设置 - > Twitter,您会看到该帐户进入该帐户并“删除帐户”

once you delete the account you will find that when you launch your app and try to login to twitter now you will be asked to sign in.

删除帐户后,您会发现当您启动应用并尝试登录Twitter时,系统会要求您登录。

Once an account is added there is no way to take out the account, (unless Twitter supports this and makes it public) The User will have to manually go into Settings -> Twitter and delete the account from there to be able to sign in to a different account.

一旦添加了帐户,就无法取出帐户,(除非Twitter支持并将其公开)用户必须手动进入设置 - > Twitter并从那里删除帐户才能登录一个不同的帐户。

Also i noticed that when you add another account into Twitter, trying to login you will be given a chance to login either account when using [[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error)

另外我注意到当你在Twitter中添加另一个帐户时,尝试登录时你将有机会在使用[[Twitter sharedInstance] logInWithCompletion时登录任一帐户:^(TWTRSession * session,NSError * error)

edit: Upon further Research if the User allows the app to use "Twitter" accounts you are able to access the Accounts Framework and delete the account from there:

编辑:进一步研究如果用户允许应用程序使用“Twitter”帐户,您可以访问帐户框架并从那里删除帐户:

https://developer.apple.com/library/mac/documentation/Accounts/Reference/ACAccountStoreClassRef/index.html

https://developer.apple.com/library/mac/documentation/Accounts/Reference/ACAccountStoreClassRef/index.html

Cheers!

干杯!