I implemented twitter on my app via Fabric. I’m trying to automate the process of composing and posting a tweet. When the user presses a button, I want a pre-filled tweet to share automatically. There are two ways I envisioned this going:
1.) Simply automate pressing the button “Post” when the dialogue appears
or
2.) Directly posting the tweet when the button is pressed, not having the pop-up appear at all
I’m having trouble figuring out how to do either and can’t find access to the pop-up UI contents.
Here is the code that initializes the button and then the actual popup:
var counter = 1
@IBAction func Share(_ sender: UIButton) {
let composer = TWTRComposer()
counter += 1
composer.setText("Times I've missed my alarm: \(counter)")
composer.setImage(UIImage(named: "fabric"))
// Called from a UIViewController
composer.show(from: self) { result in
if (result == TWTRComposerResult.cancelled) {
print("Tweet composition cancelled")
}
else {
print("Sending tweet!")
}
}
}