Skip to content

Commit

Permalink
actually request permission
Browse files Browse the repository at this point in the history
it seems to me that the function should make the attempt to request the permissions, not just checking them
  • Loading branch information
jerry2013 authored May 12, 2023
1 parent 69a162f commit 108d39f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/iosrtcPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,9 @@ class iosrtcPlugin : CDVPlugin {
switch AVCaptureDevice.authorizationStatus(for: AVMediaType.video) {
case AVAuthorizationStatus.notDetermined:
NSLog("PluginGetUserMedia#call() | video authorization: not determined")
AVCaptureDevice.requestAccess(for:.video) { granted in
status = granted
}
case AVAuthorizationStatus.restricted:
NSLog("PluginGetUserMedia#call() | video authorization: restricted")
case AVAuthorizationStatus.denied:
Expand All @@ -1239,13 +1242,16 @@ class iosrtcPlugin : CDVPlugin {
if audioRequested == true {
switch AVCaptureDevice.authorizationStatus(for: AVMediaType.audio) {
case AVAuthorizationStatus.notDetermined:
NSLog("PluginGetUserMedia#call() | video authorization: not determined")
NSLog("PluginGetUserMedia#call() | audio authorization: not determined")
AVCaptureDevice.requestAccess(for:.audio) { granted in
status = granted
}
case AVAuthorizationStatus.restricted:
NSLog("PluginGetUserMedia#call() | video authorization: restricted")
NSLog("PluginGetUserMedia#call() | audio authorization: restricted")
case AVAuthorizationStatus.denied:
NSLog("PluginGetUserMedia#call() | video authorization: denied")
NSLog("PluginGetUserMedia#call() | audio authorization: denied")
case AVAuthorizationStatus.authorized:
NSLog("PluginGetUserMedia#call() | video authorization: authorized")
NSLog("PluginGetUserMedia#call() | audio authorization: authorized")
status = true
}
}
Expand Down

0 comments on commit 108d39f

Please sign in to comment.