diff --git a/Signal/src/call/CallService.swift b/Signal/src/call/CallService.swift index f882f154d..6974cfc7f 100644 --- a/Signal/src/call/CallService.swift +++ b/Signal/src/call/CallService.swift @@ -779,6 +779,37 @@ protocol CallServiceObserver: class { func setHasLocalVideo(hasLocalVideo: Bool) { assertOnSignalingQueue() + let authStatus = AVCaptureDevice.authorizationStatus(forMediaType:AVMediaTypeVideo) + switch authStatus { + case .notDetermined: + Logger.debug("\(TAG) authStatus: AVAuthorizationStatusNotDetermined") + break + case .restricted: + Logger.debug("\(TAG) authStatus: AVAuthorizationStatusRestricted") + break + case .denied: + Logger.debug("\(TAG) authStatus: AVAuthorizationStatusDenied") + break + case .authorized: + Logger.debug("\(TAG) authStatus: AVAuthorizationStatusAuthorized") + break + } + + // TODO: We could also check this whenever the app returns from the background, + // since the user could disable this priviledge at all times. + if authStatus != .authorized { + DispatchQueue.main.async { + let title = NSLocalizedString("CAMERA_PERMISSION_MISSING_TITLE", comment: "Alert title when camera is not authorized") + let message = NSLocalizedString("CAMERA_PERMISSION_MISSING_BODY", comment: "Alert body when camera is not authorized") + let okButton = NSLocalizedString("OK", comment:"") + + let alert = UIAlertView(title:title, message:message, delegate:nil, cancelButtonTitle:okButton) + alert.show() + } + + return + } + guard let peerConnectionClient = self.peerConnectionClient else { handleFailedCall(error: .assertionError(description:"\(TAG) peerConnectionClient unexpectedly nil in \(#function)")) return diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 2970489d1..a242ee01e 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -68,7 +68,7 @@ "ATTACHMENT_QUEUED" = "New attachment queued for retrieval."; /* No comment provided by engineer. */ -"AUDIO_PERMISSION_MESSAGE" = "Signal requires access to your microphone to work properly. You can restore the permission in the Settings app >> Privacy >> Microphone >> Signal"; +"AUDIO_PERMISSION_MESSAGE" = "Signal requires access to your microphone to work properly. You can grant this permission in the Settings app >> Privacy >> Microphone >> Signal"; /* Accessibilty label for placing call button */ "CALL_LABEL" = "Call"; @@ -76,6 +76,12 @@ /* notification action */ "CALLBACK_BUTTON_TITLE" = "Call back"; +/* Alert body when camera is not authorized */ +"CAMERA_PERMISSION_MISSING_BODY" = "Signal requires access to your camera for video calls. You can grant this permission in the Settings app >> Privacy >> Camera >> Signal"; + +/* Alert title when camera is not authorized */ +"CAMERA_PERMISSION_MISSING_TITLE" = "Error"; + /* Activity Sheet label */ "COMPARE_SAFETY_NUMBER_ACTION" = "Compare with Clipboard";