【问题标题】:is it possible to have twitter log out in ios app?是否可以在 ios 应用程序中注销 twitter?
【发布时间】:2017-07-29 18:37:30
【问题描述】:

我在我的应用程序中使用了推文表发推文,效果很好,但设置后无法注销..我必须重新启动应用程序才能发推文 但我想要的是制作一个单独的登录按钮,但在 twitter 中是否可以从应用程序内的 twitter 登录和注销? 提前感谢负载:)

【问题讨论】:

    标签: ios twitter


    【解决方案1】:

    我认为这是不可能的。您必须在手机设置中注销。

    【讨论】:

    • 恐怕你是对的,无论如何谢谢你的回复 btype
    • 这是不可能的,因为这会对抗 Twitter 集成中的单点登录设计。
    • 是的,我有 btype :) 我只是在等待答案,如果我可以在 twitter 设置后返回应用程序
    【解决方案2】:

    您必须为 Twitter 登录提供自己的 UI。例如。一旦用户输入 Twitter 凭据,您可以先添加 Twitter 帐户,然后调用 Tweet 表。

    我怀疑是否可以使用 SDK 注销或删除帐户。

    添加推特账号的示例代码:

    ACAccountStore *store = [[ACAccountStore alloc] init] ;
    
            ACAccountType *twitterType = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
            [store requestAccessToAccountsWithType:twitterType withCompletionHandler:^(BOOL granted, NSError *error) {
                if(granted) {
                    ACAccount *twitterAccount = [[ACAccount alloc] initWithAccountType:[store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter]];
    
                    ACAccountCredential *outhCredential = [[ACAccountCredential alloc] initWithOAuthToken:token.key tokenSecret:token.secret];
                    twitterAccount.credential = outhCredential;
    
                    [store saveAccount:twitterAccount withCompletionHandler:^(BOOL success, NSError *error) {
                        if(success)
                        {
                            [self performSelectorOnMainThread:@selector(showTweetSheet) withObject:nil waitUntilDone:NO];
                        }
                    }];
    
                    [outhCredential release];
                    [twitterAccount release];
                    [store release];
                }
                // Handle any error state here as you wish
            }]; 
    

    【讨论】:

    • 感谢 MSK 的回复:) 我也有登录 Twitter 的代码,但请您提供一些示例代码以退出 Twitter 的设置。
    • @iShuru 我快速搜索了文档,现在我认为无法从应用程序中删除帐户(或注销)。所以在某种程度上可以登录但不能注销。
    • MSK 是的 :( 希望 twitter 很快更新那里的框架.. 但是我们可以对某些如何从 twitter 设置返回应用程序执行dismissviewcontroller 或类似的操作吗?
    • 如果您的意思是从设置应用程序返回您的应用程序,答案是否定的
    猜你喜欢
    • 2015-11-02
    • 2014-07-27
    • 2012-01-05
    • 2016-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-03
    相关资源
    最近更新 更多