Open Sam-Davis opened 5 years ago
I'm also experiencing this
Hi @Sam-Davis
I can confirm that there is indeed an issue with camera-plugin. We are going to put the bug in our plan and will provide a fix for it. You can follow this thread for further information, I'll post here once a fix is available.
We have tried to implement a workaround for this bug, but it appears that this bug is a blocker. We implemented the permissions check in a previous page:
camera.requestPermissions().then(
function success() {
which we hoped would mean that the following does not ask for permissions:
camera.requestPermissions().then(
function success() {
var options = { width: 300, keepAspectRatio: true, saveToGallery: true };
var takePictrue = camera.takePicture(options);
takePictrue.then((imageAsset: ImageAsset) => {
However, it just means that it only asks for the location. The permissions check ( camera.requestPermissions().then
will ask two questions relating to the cemeras permissions, but it does not ask for location. Then takePictrue.then
will result in permissions being asked. At this point it is too late for permissions to be requested.
I'm not sure why .takePicture is requsting the user's location. You shouldn't need to tell an app your location to take a picture.
On further investigation, this bug has a lesser impact than previously thought.
It breaks when you open the camera on a device for the first time and it says:
"Allow camera to access this device's location?" (photo location question)
It then redirects the user back to the camera app after allowing permission, rather than back to the nativescript app.
If the user first opens the camera app on the phone and responds to this photo location question and then opens the nativescript app, then the error does not occur. Therefore, this error should effect a very small proportion of users.
Hi @Sam-Davis, I can confirm your observations.
On android the camera plugin is using an Image Capture intent to take an image through a camera app installed on the device. The expected behavior is that the user doesn't leave the app while doing the image picking. However it seems that since API24, the default android camera app starts automatically if it has never been started when the plugin requests this intent.
I haven't found a way to improve the plugin in this particular scenario, but if someone has more information and ideas, PRs are welcome.
Which platform(s) does your issue occur on?
Android
Please, provide the following version numbers that your issue occurs with:
"dependencies": { "@angular/animations": "~5.2.0", "@angular/common": "~5.2.0", "@angular/compiler": "~5.2.0", "@angular/core": "~5.2.0", "@angular/forms": "~5.2.0", "@angular/http": "~5.2.0", "@angular/platform-browser": "~5.2.0", "@angular/platform-browser-dynamic": "~5.2.0", "@angular/router": "~5.2.0", "nativescript-angular": "~5.3.0", "nativescript-background-http": "^3.3.1", "nativescript-camera": "^4.0.2", "nativescript-imagepicker": "^6.0.5", "nativescript-localstorage": "^1.1.5", "nativescript-theme-core": "~1.0.4", "nativescript-toast": "^1.4.6", "nativescript-ui-sidedrawer": "~4.0.0", "reflect-metadata": "~0.1.10", "rxjs": "~5.5.5", "tns-core-modules": "^4.0.1", "zone.js": "~0.8.18" }, "devDependencies": { "@angular/compiler-cli": "~5.2.0", "@ngtools/webpack": "~1.9.4", "babel-traverse": "6.4.5", "babel-types": "6.4.5", "babylon": "6.4.5", "clean-webpack-plugin": "~0.1.19", "codelyzer": "~4.0.2", "copy-webpack-plugin": "~4.3.0", "css-loader": "~0.28.7", "extract-text-webpack-plugin": "~3.0.2", "lazy": "1.0.11", "nativescript-dev-sass": "~1.5.0", "nativescript-dev-typescript": "~0.7.0", "nativescript-dev-webpack": "~0.10.0", "nativescript-worker-loader": "~0.8.1", "raw-loader": "~0.5.1", "resolve-url-loader": "~2.2.1", "sass-loader": "~6.0.6", "tslint": "~5.8.0", "typescript": "~2.7.2", "uglifyjs-webpack-plugin": "~1.1.6", "webpack": "~3.10.0", "webpack-bundle-analyzer": "^2.9.1", "webpack-sources": "~1.1.0"
Please, tell us how to recreate the issue in as much detail as possible.
Describe the steps to reproduce it.
The first time the camera is loaded on an emulator, the user is asked for permissions. The standard permissions to access the device camera are requested, but unexpectedly the user is also asked if they want the device to have access to their location.
Whether or not the user agrees to allow the app to have access to their location, the next screen is the take photo screen (as expected). However, when the user clicks on the camera icon to take a photo, they are not shown the tick or cross asking them if they want to keep the photo. Instead the camera button displays and they can continue taking photos indefinitely.
If the user presses the back button and goes into this screen again, then the user is redirected to the page with the tick and the cross as expected.
I'm guess that this is caused by a race condition, where the take photo starts before all the permissions are approved.
The code to take the photo appears to be waiting for the permissions to have been granted:
I have asked this question on stack overflow: https://stackoverflow.com/questions/54197418/nativescript-camera-doesnt-show-tick-nor-cross-after-taking-a-photo