Skip to content

Commit

Permalink
[Feat] TeamSparker#495 - 인증 시도할 경우 카메라 권한 허용 확인 후 권한 요청
Browse files Browse the repository at this point in the history
  • Loading branch information
yangsubinn committed Apr 8, 2022
1 parent da5c4d5 commit ea44419
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,32 +200,13 @@ extension AuthUploadVC {
}

private func openCamera() {
let status = AVCaptureDevice.authorizationStatus(for: AVMediaType.video)

if status == .authorized {
// 권한 설정 되어있는 경우

// 카메라 촬영 타입이 가능하다면
if UIImagePickerController.isSourceTypeAvailable(.camera) {
// UIImagePickerController에서 어떤 식으로 image를 pick해올지 -> 카메라 촬영헤서 픽해오겠다43
picker.sourceType = .camera
present(picker, animated: false, completion: nil)
} else {
print("카메라 접근 안됨")
}

} else if status == .denied {
// 권한 설정 거부 되어있는 경우

print("⚠️ 권한 설정 거부")

} else if status == .restricted {
// 제한된 경우

print("⚠️ 제한됨")
} else if status == .notDetermined {
// 결정 안된 경우
print("⚠️ 결정 안됨")
// 카메라 촬영 타입이 가능하다면
if UIImagePickerController.isSourceTypeAvailable(.camera) {
// UIImagePickerController에서 어떤 식으로 image를 pick해올지 -> 카메라 촬영헤서 픽해오겠다43
picker.sourceType = .camera
present(picker, animated: false, completion: nil)
} else {
print("카메라 접근 안됨")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum DialogueType {
case createRoom
case exitEditProfile
case withdrawal
case cameraAccess
}

class DialogueVC: UIViewController {
Expand Down Expand Up @@ -130,6 +131,12 @@ extension DialogueVC {
resetOrExitLabel.text = "탈퇴하기"
resetOrExitLabel.textColor = .sparkDarkPinkred

case .cameraAccess:
guideLabel.text = """
카메라 접근 권한 설정
"""
resetOrExitLabel.text = "좋아용"

case .none:
print("dialogueType을 지정해주세요")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,24 +135,49 @@ extension HabitAuthVC {

@objc
private func touchOkayButton() {
let presentingVC = self.presentingViewController
switch authType {
case .photoOnly:
self.dismiss(animated: true) {
self.presentAlertClosure?()
let status = AVCaptureDevice.authorizationStatus(for: AVMediaType.video)

if status == .authorized {
// 권한 설정 되어있는 경우
let presentingVC = self.presentingViewController
switch authType {
case .photoOnly:
self.dismiss(animated: true) {
self.presentAlertClosure?()
}
case .photoTimer:
self.dismiss(animated: true) {
guard let rootVC = UIStoryboard(name: Const.Storyboard.Name.authTimer, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.authTimer) as? AuthTimerVC else { return }
let nextVC = UINavigationController(rootViewController: rootVC)
nextVC.modalPresentationStyle = .fullScreen
rootVC.roomId = self.roomID
rootVC.roomName = self.roomName

presentingVC?.present(nextVC, animated: true, completion: nil)
}
default:
print("아닙니다")
}
case .photoTimer:
self.dismiss(animated: true) {
guard let rootVC = UIStoryboard(name: Const.Storyboard.Name.authTimer, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.authTimer) as? AuthTimerVC else { return }
let nextVC = UINavigationController(rootViewController: rootVC)
nextVC.modalPresentationStyle = .fullScreen
rootVC.roomId = self.roomID
rootVC.roomName = self.roomName

presentingVC?.present(nextVC, animated: true, completion: nil)
} else if status == .denied {
// 권한 설정 거부 되어있는 경우
print("⚠️ 권한 설정 거부")

guard let dialogVC = UIStoryboard(name: Const.Storyboard.Name.dialogue, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.dialogue) as? DialogueVC else { return }

dialogVC.dialogueType = .cameraAccess
dialogVC.clousure = {
print("📸 돌아왔슴다")
UIApplication.shared.open(NSURL(string: "App-prefs:root=Photos&path=com.TeamSparker.Spark")! as URL)
}
default:
print("아닙니다")
dialogVC.modalPresentationStyle = .overFullScreen
dialogVC.modalTransitionStyle = .crossDissolve
self.present(dialogVC, animated: true, completion: nil)
} else if status == .restricted {
// 제한된 경우
print("⚠️ 제한됨")
} else if status == .notDetermined {
// 결정 안된 경우. 우리 앱은 최초에 결정을 하도록 하기 때문에 발생할 일 X
print("⚠️ 결정 안됨")
}
}

Expand Down

0 comments on commit ea44419

Please sign in to comment.