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
    • 379
    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.

    -(void)createTwitterAccount{
    
         ACAccountStore *store = [[ACAccountStore alloc]init];
    
        ACAccountType *twitterAccountType = [store
    
                                             accountTypeWithAccountTypeIdentifier:
    
                                             ACAccountTypeIdentifierTwitter];
        [store
    
         requestAccessToAccountsWithType:twitterAccountType
    
         options:NULL
    
         completion:^(BOOL granted, NSError *error) {
    
    
    
    
    
             if (granted) {
                 ACAccount *account = [self returnAcAcount:store];
    
                     [store saveAccount:account withCompletionHandler:^(BOOL success, NSError *error) {
                         if (success) {
                             //
                         }
                     }];
    
    
    
    
    
                 //  Step 2:  Create a request
    
    
    
             }
    
    
         }];
    }
    
    -(ACAccount *)returnAcAcount:(ACAccountStore *)store{
    
    
    
        //  Each account has a credential, which is comprised of a verified token and secret
        ACAccountCredential *credential =
        [[ACAccountCredential alloc] initWithOAuthToken:TWITTER_KEY tokenSecret:TWITTER_SECRET];
    
        //    
    
        //  Obtain the Twitter account type from the store
        ACAccountType *twitterAcctType =
        [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
    
        //  Create a new account of the intended type
    
        //    ACAccountTypeIdentifierTwitter
        ACAccount *newAccount = [[ACAccount alloc] initWithAccountType:twitterAcctType];
    
        //  Attach the credential for this user
        newAccount.credential = credential;
        return newAccount;
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: