Show alert when user tries to activate local video without camera permissions.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 2ef80e569d
commit da53368bc2

@ -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

@ -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";

Loading…
Cancel
Save