Since the upgrade to Xcode 9 and Swift 4, I've been quite busy in getting my apps back working again. But I'm still struggling with getting my tweet composer to work. In Xcode 8 this was still working fine...
case "Twitter":
if (Twitter.sharedInstance().sessionStore.hasLoggedInUsers()) {
// App must have at least one logged-in user to compose a Tweet
let composer = TWTRComposerViewController.emptyComposer()
UIApplication.shared.keyWindow?.rootViewController?.present(composer, animated: true, completion: nil)
} else {
// Log in, and then check again
Twitter.sharedInstance().logIn { session, error in
if session != nil { // Log in succeeded
let composer = TWTRComposerViewController.emptyComposer()
UIApplication.shared.keyWindow?.rootViewController?.present(composer, animated: true, completion: nil)
} else {
let alert = UIAlertController(title: "No Twitter Accounts Available", message: "You must log in before presenting a composer.", preferredStyle: .alert)
UIApplication.shared.keyWindow?.rootViewController?.present(alert, animated: false, completion: nil)
}
}
}
Is what I now litterly copy pasted from the Twitter kit website and adjusted because I have my sharing functions all in a seperate class.
When this piece of code is started, my Twitter application is being opened, and the authenticatin screen is opened as what I kind of expect: Authenticating
When I connect, it shows me quickly my timeline, and than just goes back to my app. Without composing window...
Anyone an idea?
Problem solved with adding this in the AppDelegate:
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
let handled:Bool = true
Twitter.sharedInstance().application(app, open: url, options: options)
return handled
}