Added delegate to prompt to app settings

This commit is contained in:
Andrew Walz 2017-08-30 21:41:03 -06:00
parent 85d9bc917c
commit ad38933dca
4 changed files with 27 additions and 7 deletions

View file

@ -184,7 +184,7 @@
}; };
1675A9711E00A68300B80903 = { 1675A9711E00A68300B80903 = {
CreatedOnToolsVersion = 8.1; CreatedOnToolsVersion = 8.1;
DevelopmentTeam = DGV5BLXSF9; DevelopmentTeam = G8E5P2X66G;
ProvisioningStyle = Automatic; ProvisioningStyle = Automatic;
}; };
}; };
@ -421,11 +421,11 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = DGV5BLXSF9; DEVELOPMENT_TEAM = G8E5P2X66G;
INFOPLIST_FILE = DemoSwiftyCam/Info.plist; INFOPLIST_FILE = DemoSwiftyCam/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0; IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.Walzy.DemoSwiftyCam; PRODUCT_BUNDLE_IDENTIFIER = com.Walzy.DemoSwiftyCam1;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0; SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
@ -436,11 +436,11 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = DGV5BLXSF9; DEVELOPMENT_TEAM = G8E5P2X66G;
INFOPLIST_FILE = DemoSwiftyCam/Info.plist; INFOPLIST_FILE = DemoSwiftyCam/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0; IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.Walzy.DemoSwiftyCam; PRODUCT_BUNDLE_IDENTIFIER = com.Walzy.DemoSwiftyCam1;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0; SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";

View file

@ -25,6 +25,7 @@ class ViewController: SwiftyCamViewController, SwiftyCamViewControllerDelegate {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
shouldPrompToAppSettings = true
cameraDelegate = self cameraDelegate = self
maximumVideoDuration = 10.0 maximumVideoDuration = 10.0
shouldUseDeviceOrientation = true shouldUseDeviceOrientation = true

View file

@ -158,6 +158,10 @@ open class SwiftyCamViewController: UIViewController {
/// Setting to true will prompt user for access to microphone on View Controller launch. /// Setting to true will prompt user for access to microphone on View Controller launch.
public var audioEnabled = true public var audioEnabled = true
/// Sets whether or not app should display prompt to app settings if audio/video permission is denied
/// If set to false, delegate function will be called to handle exception
public var shouldPrompToAppSettings = true
/// Public access to Pinch Gesture /// Public access to Pinch Gesture
fileprivate(set) public var pinchGesture : UIPinchGestureRecognizer! fileprivate(set) public var pinchGesture : UIPinchGestureRecognizer!
@ -386,8 +390,11 @@ open class SwiftyCamViewController: UIViewController {
} }
case .notAuthorized: case .notAuthorized:
// Prompt to App Settings if self.shouldPrompToAppSettings == true {
self.promptToAppSettings() self.promptToAppSettings()
} else {
self.cameraDelegate?.swiftyCamNotAuthorized(self)
}
case .configurationFailed: case .configurationFailed:
// Unknown Error // Unknown Error
DispatchQueue.main.async { DispatchQueue.main.async {

View file

@ -104,6 +104,14 @@ public protocol SwiftyCamViewControllerDelegate: class {
*/ */
func swiftyCamDidFailToConfigure(_ swiftyCam: SwiftyCamViewController) func swiftyCamDidFailToConfigure(_ swiftyCam: SwiftyCamViewController)
/**
SwiftyCamViewControllerDelegate function called when when SwiftyCamViewController does not have access to camera or microphone.
- Parameter swiftyCam: Current SwiftyCamViewController
*/
func swiftyCamNotAuthorized(_ swiftyCam: SwiftyCamViewController)
} }
public extension SwiftyCamViewControllerDelegate { public extension SwiftyCamViewControllerDelegate {
@ -148,6 +156,10 @@ public extension SwiftyCamViewControllerDelegate {
func swiftyCamDidFailToConfigure(_ swiftyCam: SwiftyCamViewController) { func swiftyCamDidFailToConfigure(_ swiftyCam: SwiftyCamViewController) {
// Optional // Optional
} }
func swiftyCamNotAuthorized(_ swiftyCam: SwiftyCamViewController) {
// Optional
}
} }