Added hasCameraPermission on Android
This commit is contained in:
parent
7f3a26f3ca
commit
7101772fd9
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue