0

I am integrating twitter into my application. I m success to open twitter page, but SA_OAuthTwitterEngine Delegate method not called,below is my code.

On twitter button click

-(void)twitterLogin
{
    [self twitterLogout];
    if(!_engine)
    {
        _engine=[[[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate: self]autorelease];
        _engine.consumerKey=NSLocalizedString(@"consumerKey", nil);
        _engine.consumerSecret=NSLocalizedString(@"consumerSecret", nil);
    }

    UIViewController *controller=[SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine:_engine delegate:self];
    if (controller)
    {
        [self presentModalViewController:controller animated:YES];
    }
 }

-(void)twitterLogout
{    
    NSHTTPCookieStorage* cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage];
    for (NSHTTPCookie* cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {
        [cookies deleteCookie:cookie];
    }
    [_engine clearAccessToken];
    [_engine release];
    _engine=nil;
}

This method work perfectly but below method not called

- (void) storeCachedTwitterOAuthData: (NSString *) data forUsername: (NSString *) username 
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    [defaults setObject: data forKey: @"authData"];
    [defaults synchronize];
    NSLog(@"%@",username);

}

Thank you in advance.

Birju
  • 1,132
  • 11
  • 32

1 Answers1

-1

do something like this

`if(!_engine){  
        _engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate:self];  
        _engine.consumerKey    = kOAuthConsumerKey;  
        _engine.consumerSecret = kOAuthConsumerSecret;  
    }   
    if(![_engine isAuthorized]){  
        UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine:_engine delegate:self];  

    if (controller){  
        [parent presentModalViewController: controller animated: YES];


        //hasTWLoggedInBefore=YES;
    }  
}  else{

    NSLog(@"IT IS ALRADY LOGIN");
    // Inform the delegate that Login is successful
    if ( [delegate respondsToSelector:@selector(TWloginStatus:)] ) 
    {
        // calling delegate method. For this method to function, the delegate should be implemented in the calling class.
        [delegate TWloginStatus:YES];               
        return;
    }       }` to load the twitter.
IronManGill
  • 7,222
  • 2
  • 31
  • 52
hacker
  • 8,919
  • 12
  • 62
  • 108