@@ -29,6 +29,10 @@ editUrl: https://github.com/NativeScript/plugins/tree/main/packages/camera/READM
2929
3030A plugin that allows you to take a picture and optionally save it on the device storage.
3131
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+
3236## Installation
3337
3438To 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
6670``` TypeScript
6771import { requestPermissions } from ' @nativescript/camera' ;
6872
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+
79103```
80104
81105:::tip Note
0 commit comments