     
     // MARK: - Public functions
     
-    public func present(from viewController: UIViewController, title: String? = nil, message: String? = nil, image: UIImage? = nil, buttonImage: UIImage? = nil, buttonTitle: String = NSLocalizedString("OK", comment: "Button title to dismiss alert"), onDismiss: (() -> Void)? = nil, onRightButton: (() -> Void)? = nil) {
+    public func present(from viewController: UIViewController, for duration: TimeInterval? = nil, title: String? = nil, message: String? = nil, image: UIImage? = nil, buttonImage: UIImage? = nil, buttonTitle: String = NSLocalizedString("OK", comment: "Button title to dismiss alert"), onDismiss: (() -> Void)? = nil, onRightButton: (() -> Void)? = nil) {
+        timer?.invalidate()
         let config = Config(alertTitle: title, alertMessage: message, alertImage: image, buttonImage: buttonImage, buttonTitle: buttonTitle, onRightButton: onRightButton, onDismiss: onDismiss)
+        if let duration = duration {
+            timer = Timer.scheduledTimer(timeInterval: duration, target: self, selector: #selector(closeAlert), userInfo: nil, repeats: false)
+        }
         if viewController.presentedViewController == self {
             reshowAlert(with: config)
         } else {
             self.config = config
             viewController.present(self, animated: false)
         }
+    }
+    
+    public func dismissAlert() {
+        closeAlert()
     }
     
     

    }
    
    @IBAction func closeAlert() {
        hideAlert {
            self.config.onDismiss?()
            self.dismiss(animated: false)

    }
    
    
    // MARK: - Private properties
    
    fileprivate var timer: Timer?
    
    
    // MARK: - Constants
    
    fileprivate static let topOffset: CGFloat = -200.0
