                     setButtonUnauthorizedStyle(button)
                     button.setTitle("Denied \(type.rawValue)".uppercaseString, forState: UIControlState.Normal)
                 }
+            case .Microphone:
+                if statusCamera() == .Authorized {
+                    setButtonAuthorizedStyle(button)
+                    button.setTitle("Allowed \(type.rawValue)".uppercaseString, forState: UIControlState.Normal)
+                } else if statusCamera() == .Unauthorized {
+                    setButtonUnauthorizedStyle(button)
+                    button.setTitle("Denied \(type.rawValue)".uppercaseString, forState: UIControlState.Normal)
+                }
+            case .Camera:
+                if statusCamera() == .Authorized {
+                    setButtonAuthorizedStyle(button)
+                    button.setTitle("Allowed \(type.rawValue)".uppercaseString, forState: UIControlState.Normal)
+                } else if statusCamera() == .Unauthorized {
+                    setButtonUnauthorizedStyle(button)
+                    button.setTitle("Denied \(type.rawValue)".uppercaseString, forState: UIControlState.Normal)
                 }
             }
 

import UIKit
import CoreLocation
import AddressBook
//    case Microphone
//    case Camera
import AVFoundation

public enum PermissionType: String {

            self.showDeniedAlert(.Notifications)
        }
    }
    
    public func statusMicrophone() -> PermissionStatus {
        let status = AVAudioSession.sharedInstance().recordPermission()
        if status == .Granted {
            return .Authorized
        } else if status == .Denied {
            return .Unauthorized
        }
        
        return .Unknown
    }
    
    func requestMicrophone() {
        if statusMicrophone() == .Unknown {
            AVAudioSession.sharedInstance().requestRecordPermission({ (granted) -> Void in
                self.detectAndCallback()
            })
        } else if statusMicrophone() == .Unauthorized {
            // TODO: Alert. User must go to Settings.
            self.showDeniedAlert(.Microphone)
        }
    }
    
    public func statusCamera() -> PermissionStatus {
        let status = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo)
        switch status {
        case .Authorized:
            return .Authorized
        case .Restricted, .Denied:
            return .Unauthorized
        case .NotDetermined:
            return .Unknown
        }
    }
    
    func requestCamera() {
        if statusCamera() == .Unknown {
            AVCaptureDevice.requestAccessForMediaType(AVMediaTypeVideo,
                completionHandler: { (granted) -> Void in
                    self.detectAndCallback()
            })
        } else if statusCamera() == .Unauthorized {
            // TODO: Alert. User must go to Settings.
            self.showDeniedAlert(.Camera)
        }
    }

