How can I press the OK button in a JS alert programmatically?
What I want to do: every time after the alert is created, the OK button is pressed.
This is for
Swift 3
you want to try this code in show alert and ok and cancel button
let sharephotoAction = UIAlertController.init(title: "Confirm Ticket", message:"Please Collect Your Ticket Before 1 Hours Ago in Location", preferredStyle: .alert )
sharephotoAction.addAction(UIAlertAction(title: "Ok", style: .default, handler: { (alertAction) in
_ = Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(self.Save), userInfo: nil, repeats: false)
}))
sharephotoAction.addAction(UIAlertAction(title: "Cancle", style: .default, handler:nil))
self.present(sharephotoAction, animated: true, completion:nil)