@@ -29,6 +29,10 @@ editUrl: https://github.com/NativeScript/plugins/tree/main/packages/camera/READM
29
29
30
30
A plugin that allows you to take a picture and optionally save it on the device storage.
31
31
32
+ ** Note: Version 7 contains breaking changes:**
33
+
34
+ - New behavior on requesting permissions, detailed in [ Request for user permissions] ( #request-for-user-permissions ) .
35
+
32
36
## Installation
33
37
34
38
To install the plugin, run the following command in the root directory of your project:
@@ -66,16 +70,36 @@ To prompt the user to grant or deny your app access to their camera and photo ga
66
70
``` TypeScript
67
71
import { requestPermissions } from ' @nativescript/camera' ;
68
72
69
- requestPermissions ().then (
70
- function success() {
71
- // permission request accepted or already granted
72
- // ... call camera.takePicture here ...
73
- },
74
- function failure() {
75
- // permission request rejected
76
- // ... tell the user ...
77
- }
78
- );
73
+ const perms = await camera .requestPermissions ();
74
+
75
+ if (perms .Success ) {
76
+ // permission request accepted or already granted
77
+ // ... call camera.takePicture here ...
78
+ } else {
79
+ // permission request rejected
80
+ // ... tell the user ...
81
+ const cameraPermissionSuccess = perms .Details .Camera .Success ;
82
+ const photoPermissionSuccess = perms .Details .Photo .Success
83
+ }
84
+
85
+ ```
86
+
87
+ If specifying the ` saveToGallery = false ` option, you can call the ` requestCameraPermissions ` method.
88
+
89
+ ``` TypeScript
90
+ import { requestPermissions } from ' @nativescript/camera' ;
91
+
92
+ const perms = await camera .requestCameraPermissions ();
93
+
94
+ if (perms .Success ) {
95
+ // permission request accepted or already granted
96
+ // ... call camera.takePicture here ...
97
+ } else {
98
+ // permission request rejected
99
+ // ... tell the user ...
100
+
101
+ }
102
+
79
103
```
80
104
81
105
:::tip Note
0 commit comments