Twitter result incorrect after unsuccessful posting attempt

When using TWTweetComposeViewController in IOS5 to compose and send a Tweet, Tweet is if a duplicate, it displays an error message stating that the Tweet is redundant and can not be sent, but TWTweetComposeViewControllerCompletionHandler still gets the value of the result TWTweetComposeViewControllerResultDone , not TWTweetComposeViewControllerResultCancelled .

(This can happen in other cases, and not just for duplicate tweets - I did not check).

This makes it impossible to display a confirmation message to the user after successful sending, because the handler gets the same “Finish” result, whether the transfer was successful or not.

Is there any other way to check if the dispatch was really successful?

+8
ios ios5 twitter
source share
4 answers

The documentation for TWTweetComposeViewController completeHandler states the following:

The handler has a single parameter that indicates whether the user has ended or canceled by composing a tweet.

The completion handler tells you whether the user has actually finished or canceled composing the tweet itself, regardless of the result of the actual publication of the tweet.

Refresh

I looked at this a bit, and it seems like TWTweetComposeViewController is one of those convenience classes that takes up most of the developer’s work in exchange for not allowing the developer to process anything on their own. In this case, the developer is not able to handle errors that occur when sending a tweet, and must rely on the warning dialog boxes provided by iOS to inform the user.

You can hack this using the Saleh method, although I don't find it safe enough for use in a real application. See Comments in your answer.

Another method is to use your own view controller, which handles tweets and submissions. You can do this by executing the following procedure https://stackoverflow.com/a/414829/

+3
source share

Check for a warning message, if a warning message is displayed, you can find out that an error has occurred. I think the warning message is being added to the window. You can check the number of sub-windows, if they increase when you call the delegate function, you will know that an error has occurred.

+1
source share

Isn't that just a view controller? The result of the view controller is excellent because it indicates what happened to the view controller ( done is done ).

What do you post your tweet with? This library most likely has some things you can use to determine if your tweet was sent successfully or not.

-one
source share
  [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { if([urlResponse statusCode]==200) { //Tweet tweeted successfully.... } } 

it can help you. In the answer, if the url response code is 200, you can say the text is tweeted ....

-one
source share

All Articles