From ad38933dca2db98ede52f65f17eaa9e4d6eba131 Mon Sep 17 00:00:00 2001 From: Andrew Walz Date: Wed, 30 Aug 2017 21:41:03 -0600 Subject: [PATCH] Added delegate to prompt to app settings --- .../DemoSwiftyCam.xcodeproj/project.pbxproj | 10 +++++----- DemoSwiftyCam/DemoSwiftyCam/ViewController.swift | 1 + Source/SwiftyCamViewController.swift | 11 +++++++++-- Source/SwiftyCamViewControllerDelegate.swift | 12 ++++++++++++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/DemoSwiftyCam/DemoSwiftyCam.xcodeproj/project.pbxproj b/DemoSwiftyCam/DemoSwiftyCam.xcodeproj/project.pbxproj index 6af0d11..b8b883f 100644 --- a/DemoSwiftyCam/DemoSwiftyCam.xcodeproj/project.pbxproj +++ b/DemoSwiftyCam/DemoSwiftyCam.xcodeproj/project.pbxproj @@ -184,7 +184,7 @@ }; 1675A9711E00A68300B80903 = { CreatedOnToolsVersion = 8.1; - DevelopmentTeam = DGV5BLXSF9; + DevelopmentTeam = G8E5P2X66G; ProvisioningStyle = Automatic; }; }; @@ -421,11 +421,11 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = DGV5BLXSF9; + DEVELOPMENT_TEAM = G8E5P2X66G; INFOPLIST_FILE = DemoSwiftyCam/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.Walzy.DemoSwiftyCam; + PRODUCT_BUNDLE_IDENTIFIER = com.Walzy.DemoSwiftyCam1; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -436,11 +436,11 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = DGV5BLXSF9; + DEVELOPMENT_TEAM = G8E5P2X66G; INFOPLIST_FILE = DemoSwiftyCam/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.Walzy.DemoSwiftyCam; + PRODUCT_BUNDLE_IDENTIFIER = com.Walzy.DemoSwiftyCam1; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/DemoSwiftyCam/DemoSwiftyCam/ViewController.swift b/DemoSwiftyCam/DemoSwiftyCam/ViewController.swift index 17c6a5c..6f9636c 100644 --- a/DemoSwiftyCam/DemoSwiftyCam/ViewController.swift +++ b/DemoSwiftyCam/DemoSwiftyCam/ViewController.swift @@ -25,6 +25,7 @@ class ViewController: SwiftyCamViewController, SwiftyCamViewControllerDelegate { override func viewDidLoad() { super.viewDidLoad() + shouldPrompToAppSettings = true cameraDelegate = self maximumVideoDuration = 10.0 shouldUseDeviceOrientation = true diff --git a/Source/SwiftyCamViewController.swift b/Source/SwiftyCamViewController.swift index 332e0c4..5f51dab 100644 --- a/Source/SwiftyCamViewController.swift +++ b/Source/SwiftyCamViewController.swift @@ -158,6 +158,10 @@ open class SwiftyCamViewController: UIViewController { /// Setting to true will prompt user for access to microphone on View Controller launch. 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 fileprivate(set) public var pinchGesture : UIPinchGestureRecognizer! @@ -386,8 +390,11 @@ open class SwiftyCamViewController: UIViewController { } case .notAuthorized: - // Prompt to App Settings - self.promptToAppSettings() + if self.shouldPrompToAppSettings == true { + self.promptToAppSettings() + } else { + self.cameraDelegate?.swiftyCamNotAuthorized(self) + } case .configurationFailed: // Unknown Error DispatchQueue.main.async { diff --git a/Source/SwiftyCamViewControllerDelegate.swift b/Source/SwiftyCamViewControllerDelegate.swift index 764b2c7..120312e 100644 --- a/Source/SwiftyCamViewControllerDelegate.swift +++ b/Source/SwiftyCamViewControllerDelegate.swift @@ -104,6 +104,14 @@ public protocol SwiftyCamViewControllerDelegate: class { */ 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 { @@ -148,6 +156,10 @@ public extension SwiftyCamViewControllerDelegate { func swiftyCamDidFailToConfigure(_ swiftyCam: SwiftyCamViewController) { // Optional } + + func swiftyCamNotAuthorized(_ swiftyCam: SwiftyCamViewController) { + // Optional + } }