Skip to content

Commit

Permalink
fix: Always return authorized for requestPermission on SDK 22 and b…
Browse files Browse the repository at this point in the history
…elow (#344)
  • Loading branch information
mrousavy committed Aug 9, 2021
1 parent d64f372 commit 494925c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions android/src/main/java/com/mrousavy/camera/CameraViewModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ class CameraViewModule(reactContext: ReactApplicationContext) : ReactContextBase

@ReactMethod
fun requestCameraPermission(promise: Promise) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
// API 21 and below always grants permission on app install
return promise.resolve("authorized")
}

val activity = reactApplicationContext.currentActivity
if (activity is PermissionAwareActivity) {
val currentRequestCode = RequestCode++
Expand All @@ -306,6 +311,11 @@ class CameraViewModule(reactContext: ReactApplicationContext) : ReactContextBase

@ReactMethod
fun requestMicrophonePermission(promise: Promise) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
// API 21 and below always grants permission on app install
return promise.resolve("authorized")
}

val activity = reactApplicationContext.currentActivity
if (activity is PermissionAwareActivity) {
val currentRequestCode = RequestCode++
Expand Down

0 comments on commit 494925c

Please sign in to comment.