//
//  ShowAlert.swift
//  Em-call
//
//  Created by Alex Sh on 22.02.2022.
//

import Foundation
import UIKit

class ShowAlert: UIViewController {
    func showAlertLocation(title:String,message:String?,url:URL?) {
        let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
        let cancelAction = UIAlertAction(title: "Cancel", style: .default,handler:nil)
        let settingsAction = UIAlertAction(title: "Options", style: .default) { (alert) -> Void in
            if let url = url  {
              //  if #available(iOS 10.0, *) {
                    UIApplication.shared.open(url, options: [:], completionHandler: nil)
               /* } else {
                    // Fallback on earlier versions
                }*/
            }
        }
                alert.addAction(cancelAction)
                alert.addAction(settingsAction)
                self.present(alert, animated: true, completion: nil)
    }
    
    func showAlertSample(title:String, message:String?) {
        DispatchQueue.main.async {
           // self.showAlert.showAlertSample(title: "Warning",message: "Enter new contact does not match Retry new contact")
               let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
            alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
               self.present(alert, animated: true)
            }
        
       // let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
   /* alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
        switch action.style{
            case .default:
            print("default")
            
            case .cancel:
            print("cancel")
            
            case .destructive:
            print("destructive")
            
        @unknown default:
            fatalError("Fatal error")
        }
    }))*/
      //  let okAction = UIAlertAction(title: "OK", style: .default,handler:nil)
       // alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
       // alert.addAction(okAction)
      //  self.present(alert, animated: true, completion: nil)
    }
}
