Added hasCameraPermission on Android

This commit is contained in:
Yedidya Kennard 2016-08-24 13:24:12 +03:00
parent 7f3a26f3ca
commit 7101772fd9
2 changed files with 14 additions and 0 deletions

View File

@ -1,6 +1,8 @@
package com.wix.RNCameraKit.camera; package com.wix.RNCameraKit.camera;
import android.Manifest;
import android.hardware.Camera; import android.hardware.Camera;
import android.support.v4.content.PermissionChecker;
import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
@ -60,4 +62,11 @@ public class CameraModule extends ReactContextBaseJavaModule {
public void capture(boolean saveToCameraRoll, final Promise promise) { public void capture(boolean saveToCameraRoll, final Promise promise) {
new Capture(getReactApplicationContext()).execute(promise); new Capture(getReactApplicationContext()).execute(promise);
} }
@ReactMethod
public void hasCameraPermission(Promise promise) {
boolean hasPermission = PermissionChecker.checkSelfPermission(getReactApplicationContext(), Manifest.permission.CAMERA)
== PermissionChecker.PERMISSION_GRANTED;
promise.resolve(hasPermission);
}
} }

View File

@ -42,4 +42,9 @@ export default class CameraKitCamera extends React.Component {
return success; return success;
} }
static async hasCameraPermission() {
const success = await NativeCameraModule.hasCameraPermission();
return success;
}
} }