<small id='Stsgz'></small><noframes id='Stsgz'>

<tfoot id='Stsgz'></tfoot>

  1. <i id='Stsgz'><tr id='Stsgz'><dt id='Stsgz'><q id='Stsgz'><span id='Stsgz'><b id='Stsgz'><form id='Stsgz'><ins id='Stsgz'></ins><ul id='Stsgz'></ul><sub id='Stsgz'></sub></form><legend id='Stsgz'></legend><bdo id='Stsgz'><pre id='Stsgz'><center id='Stsgz'></center></pre></bdo></b><th id='Stsgz'></th></span></q></dt></tr></i><div id='Stsgz'><tfoot id='Stsgz'></tfoot><dl id='Stsgz'><fieldset id='Stsgz'></fieldset></dl></div>

  2. <legend id='Stsgz'><style id='Stsgz'><dir id='Stsgz'><q id='Stsgz'></q></dir></style></legend>

      <bdo id='Stsgz'></bdo><ul id='Stsgz'></ul>
    1. 从 iOS 中的 Twitter 框架获取 Twitter 句柄

      时间:2023-05-18
      <tfoot id='RoGI4'></tfoot>

      <i id='RoGI4'><tr id='RoGI4'><dt id='RoGI4'><q id='RoGI4'><span id='RoGI4'><b id='RoGI4'><form id='RoGI4'><ins id='RoGI4'></ins><ul id='RoGI4'></ul><sub id='RoGI4'></sub></form><legend id='RoGI4'></legend><bdo id='RoGI4'><pre id='RoGI4'><center id='RoGI4'></center></pre></bdo></b><th id='RoGI4'></th></span></q></dt></tr></i><div id='RoGI4'><tfoot id='RoGI4'></tfoot><dl id='RoGI4'><fieldset id='RoGI4'></fieldset></dl></div>
          • <bdo id='RoGI4'></bdo><ul id='RoGI4'></ul>
            <legend id='RoGI4'><style id='RoGI4'><dir id='RoGI4'><q id='RoGI4'></q></dir></style></legend>
                <tbody id='RoGI4'></tbody>

                <small id='RoGI4'></small><noframes id='RoGI4'>

              1. 本文介绍了从 iOS 中的 Twitter 框架获取 Twitter 句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我知道要在 iOS 5 中使用 twitter 框架访问已配置的 twitter 帐户,可以执行以下操作:

                I know that to get access to a configured twitter account using twitter framework in iOS 5, the following can be done:

                ACAccountStore *t_account = [[ACAccountStore alloc] init];
                ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
                [account requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) {
                    if (granted == YES) {
                    }
                }
                

                但问题是我不需要完整的帐户,如果他在 Twitter 帐户上配置了任何名称,我只想要 Twitter 名称.那么,有没有一种方法可以从框架(不是完整帐户)仅获取 twitter 句柄无需任何用户许可 ?

                But the problem is that I don't have need for a full account, I just want the twitter name if he has configured any on the twitter accounts. So, Is there a way to get just the twitter handle from the framework (not the full account) without asking any user permission ?

                推荐答案

                未经用户授予访问这些帐户的权限,您将无法访问任何帐户.只需在新项目的应用程序委托中尝试以下操作,您就知道该应用程序没有被授予访问 twitter 帐户的权限.当然,请确保您在设备或模拟器中至少有一个 twitter 帐户,并且在您的项目和应用程序委托中导入了帐户框架.此外,您还假设用户只有一个 Twitter 帐户.最好为用户可能拥有多个帐户的情况编写代码.

                You won't get access to any accounts without the user granting permission to access those accounts. Just try through the following in an app delegate in a new project so you know that app has not been given permissions to access the twitter accounts. Of course make sure you have at least one twitter account on the device or in the simulator and the accounts framework imported in your project and app delegate. Also you are making the assumption that the user has only one twitter account. Best to code for a case where a user may have more than one account.

                    ACAccountStore *accountStore = [[ACAccountStore alloc] init];
                
                    // Create an account type that ensures Twitter accounts are retrieved.
                    ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
                
                    NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
                
                    for (ACAccount *account in accountsArray ) {
                        NSLog(@"Account name: %@", account.username);
                    }
                
                    NSLog(@"Accounts array: %d", accountsArray.count);
                

                现在更改代码以在用户授予权限时返回您的结果:

                Now change the code to return your results when a user has granted permission:

                    ACAccountStore *accountStore = [[ACAccountStore alloc] init];
                
                    // Create an account type that ensures Twitter accounts are retrieved.
                    ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
                
                    [accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) {
                
                    if(granted) {
                
                        NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
                
                        for (ACAccount *account in accountsArray ) {
                            NSLog(@"Account name: %@", account.username);
                        }
                
                        NSLog(@"Accounts array: %d", accountsArray.count);
                    }
                }];
                

                所以我想简短的回答是,苹果要求用户授予用户帐户权限是有原因的.如果未授予该访问权限,您将不会取回任何数据.

                So I guess the short answer is, there is a reason apple ask the user to grant permission to user accounts. If that access has not been granted you aren't going to get any data back.

                这篇关于从 iOS 中的 Twitter 框架获取 Twitter 句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:在 iOS 框架中嵌入 .dylib 下一篇:需要导入 UIKit 的新项目文件

                相关文章

                <legend id='yxARV'><style id='yxARV'><dir id='yxARV'><q id='yxARV'></q></dir></style></legend>
                <i id='yxARV'><tr id='yxARV'><dt id='yxARV'><q id='yxARV'><span id='yxARV'><b id='yxARV'><form id='yxARV'><ins id='yxARV'></ins><ul id='yxARV'></ul><sub id='yxARV'></sub></form><legend id='yxARV'></legend><bdo id='yxARV'><pre id='yxARV'><center id='yxARV'></center></pre></bdo></b><th id='yxARV'></th></span></q></dt></tr></i><div id='yxARV'><tfoot id='yxARV'></tfoot><dl id='yxARV'><fieldset id='yxARV'></fieldset></dl></div>

                1. <tfoot id='yxARV'></tfoot>
                    • <bdo id='yxARV'></bdo><ul id='yxARV'></ul>

                    <small id='yxARV'></small><noframes id='yxARV'>