When you are going to be accessing the camera you must check that your application has been allowed access. To this end the extension provides several helpers to check and request access to the camera. Normal permission rules apply here.
On Android these permissions are listed through the manifest additions.
On older versions of Android these permissions are accepted when the user installs the application.
More modern versions (Marshmallow 6 [v23]+) require that you request the permissions similar to iOS.
You will still need to list them in your manifest and then follow the same code below as for iOS, except that on Android you will be able to ask multiple times.
You should respect the
SHOULD_EXPLAIN status by displaying additional information to your user about why you require this functionality.
On iOS the user must be asked at runtime, which you only get one chance to ask, after which you must direct the user to manually change the permissions in the settings.
The following code will work across both platforms:
There are several types of authorisation that you will require for this extension and as they may not be required by all applications they have been separated so you can request them individually as appropriate for your application:
AuthorisationType.CAMERA: Access to the camera device
AuthorisationType.PHOTOS: Access to the camera roll to save images (only required if you set
truein a capture request)
You will need to run through the above process for each of the permissions your application requires!
If your user has denied access to the camera in some situations you can prompt them to enable them and then redirect them to your application device settings, which will allow your user to change the setting.
This is especially important on iOS where you only get one attempt to ask your user for permission.
To redirect your user simply call the
You can use the
canOpenDeviceSettings flag to check if the current device supports this functionality.