Question

I was using Twitter Oath for twitter sharing, suddenly the same code is getting crashed when i tap Tweet button.

App is Crashing while twitter oath is sending update request.

here is code of sharing option

-(IBAction)ShareWithTwitter:(id)sender
{
    NSLog(@"Tweet !!!");

if(!_engine)
{
    _engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate:self];
    _engine.consumerKey    =kOAuthConsumerKey;

    _engine.consumerSecret = kOAuthConsumerSecret;  
}
else
{

    _engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate:self];
    _engine.consumerKey    =kOAuthConsumerKey;

    _engine.consumerSecret = kOAuthConsumerSecret;  


}

UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine:_engine delegate:self];

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


}

And this code is for Tweet !! (where app is crashing).

-(IBAction)updateTwitter:(id)sender
{
activityIndicatorView.hidden=NO;
activityIndicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
[activityIndicatorView startAnimating];

[tweetTextField resignFirstResponder];

NSString *strToPostOnTwitter = @"Hello Happy New Year to All !!!";

NSLog(@"String to Post is : %@",strToPostOnTwitter);

//Twitter Integration Code Goes Here
[_engine sendUpdate:strToPostOnTwitter];

//btnTwitter.hidden = YES;

}
Was it helpful?

Solution

If you are testing it on iOS 5, many times, it will not even generate a token properly. The twitter engine you are using works only with iOS4.

Now coming to your code, as the token is not generated and without it, you will be trying to post the message and so it crashed. I did a lot of research for the past one month and I decided to implement this way: If is iOS 5 device in which you are running the app, use twitter framework. else use MGTwitterEngine.

Look for the following URL's
http://iosdevelopertips.com/core-services/ios-5-twitter-framework-part-1.html
http://iosdevelopertips.com/core-services/ios-5-twitter-framework-part-2.html
http://iosdevelopertips.com/core-services/ios-5-twitter-framework-%E2%80%93-part-3.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top