iOS 11 - TwitterKit 3 - The presenting view controller dismisses on clicking Done button in the web top left



I am using the following code to compose a tweet ,
let composer = TWTRComposer()
composer.setURL(shareLinkUrl) fromController) { (result) in
if (result == .done) {
print(“Successfully composed Tweet”)
} else {
print(“Cancelled composing”)

If the user is not logged in , a web view appears asking the user to log in . If clicked on “Done” button on top left , the view controller it is presented from is dismissed and the rootViewController is loaded.


This is happening to me as well. I have a very delicate view controller flow and it is resulting in a bad state as well. Hope it gets fixed soon.


same issue .Im using TwitterKit 3, still have this. Did anyone workaround this issue?


I reported this same behavior in detail in September here: TwitterKit is dismissing callee controller in airplane mode, which didn’t seem to get any official response. May have been because of the title of original post. I ended up creating a hack-y workaround, but would love to see an official response / fix.


What hack-y workaround did you end up doing?


Hi Pavan- I’d hope that this has been fixed, as it was occurring in TwitterKit 3.1.1 and the current version is 3.3.0. But I haven’t verified it myself.

The hack involved setting a boolean property flag on the view controller when performing the twitterkit auth / sharing, and clearing it in the auth / share success callback. Then overriding the dismissViewControllerAnimated:completion: method in the view controller to check the flag like so (Obj-C):

- (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion {
    if (self.stopDismiss) {
    return [super dismissViewControllerAnimated:flag completion:completion];

This effectively blocks the calls to dismiss the presenting VC until the auth / share completes.


Twitter guys , your killing us.

This is still a huge issue we have everywhere.
The solution on top is just irrelevant for us and is a huge hack.


Unfortunately, when I try this the Safari View Controller isn’t dismissed when it actually should (i.e. when the authentication was successful). There seems to be no way to distinguish inside dismissViewControllerAnimated whether the authentication was successful or cancelled by the user.


I’ve been dealing with this bug since this morning, but I could have sworn it was behaving properly last week. But just 2m ago, it started working again. This is what I found.

For some reason, the auth web site was coming up all day today with “Done” instead of “Cancel” in the upper left. And then just now it came up with “Cancel”.

When the page comes up with “Done”, my parent login view dismisses with it.
When the page comes up with “Cancel”, my parent login view stays up.

I’m not sure if I just happened to be using it when it switched or not. However, I will say that I was testing logins all morning to see how I can fix this blasted dismiss bug. I can’t explain why the auth web site switched from “Done” to “Cancel” all of a sudden.


Using latest twiiterkit, but still facing the same issue.
Twitter team, please solve this as soon as possible and please update us.