Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to add Twitter account in your iPhone

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 404
    Comment on it

    The following code will help you to create your twitter account in your iPhone through coding. Also please note this code will only run in ios7 or later.

    1. -(void)createTwitterAccount{
    2.  
    3. ACAccountStore *store = [[ACAccountStore alloc]init];
    4.  
    5. ACAccountType *twitterAccountType = [store
    6.  
    7. accountTypeWithAccountTypeIdentifier:
    8.  
    9. ACAccountTypeIdentifierTwitter];
    10. [store
    11.  
    12. requestAccessToAccountsWithType:twitterAccountType
    13.  
    14. options:NULL
    15.  
    16. completion:^(BOOL granted, NSError *error) {
    17.  
    18.  
    19.  
    20.  
    21.  
    22. if (granted) {
    23. ACAccount *account = [self returnAcAcount:store];
    24.  
    25. [store saveAccount:account withCompletionHandler:^(BOOL success, NSError *error) {
    26. if (success) {
    27. //
    28. }
    29. }];
    30.  
    31.  
    32.  
    33.  
    34.  
    35. // Step 2: Create a request
    36.  
    37.  
    38.  
    39. }
    40.  
    41.  
    42. }];
    43. }
    44.  
    45. -(ACAccount *)returnAcAcount:(ACAccountStore *)store{
    46.  
    47.  
    48.  
    49. // Each account has a credential, which is comprised of a verified token and secret
    50. ACAccountCredential *credential =
    51. [[ACAccountCredential alloc] initWithOAuthToken:TWITTER_KEY tokenSecret:TWITTER_SECRET];
    52.  
    53. //
    54.  
    55. // Obtain the Twitter account type from the store
    56. ACAccountType *twitterAcctType =
    57. [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
    58.  
    59. // Create a new account of the intended type
    60.  
    61. // ACAccountTypeIdentifierTwitter
    62. ACAccount *newAccount = [[ACAccount alloc] initWithAccountType:twitterAcctType];
    63.  
    64. // Attach the credential for this user
    65. newAccount.credential = credential;
    66. return newAccount;
    67. }

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: