Skip to content

Commit 72215c9

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/flavor-snippets
2 parents d3514fe + 823029d commit 72215c9

File tree

4 files changed

+72
-661
lines changed

4 files changed

+72
-661
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ node_modules
77

88
explore/
99

10-
yarn.lock
1110
.DS_Store

content/plugins/camera.md

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ editUrl: https://github.com/NativeScript/plugins/tree/main/packages/camera/READM
2929

3030
A 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

3438
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
6670
```TypeScript
6771
import { 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

content/snacks/index.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,26 @@ Each Snack reveals NativeScript's power, from UI tricks to platform SDK usages t
418418
videoTitle:
419419
"Example of how to configure tab navigation with lots of options.",
420420
},
421+
{
422+
id: 23,
423+
title: "Screen Snapshot",
424+
href: "https://stackblitz.com/edit/nativescript-screen-snapshot?file=src%2Fhome.component.html",
425+
description:
426+
"Example of how to take a snapshot of any view on screen.",
427+
categories: [
428+
{
429+
title: "iOS CALayer render",
430+
href: "https://developer.apple.com/documentation/quartzcore/calayer/render(in:)",
431+
},
432+
{
433+
title: "Android createBitmap",
434+
href: "https://developer.android.com/reference/android/graphics/Bitmap#createBitmap(android.graphics.Bitmap,%20int,%20int,%20int,%20int)",
435+
},
436+
],
437+
videoUrl: "https://youtube.com/embed/ORp4y2tbJUA",
438+
videoTitle:
439+
"Screen Snapshot",
440+
},
421441
];
422442

423443
</script>

0 commit comments

Comments
 (0)