8000 chore(update-plugins): Sun Sep 17 08:04:57 UTC 2023 · NativeScript/docs-v8@38e62c0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 38e62c0

Browse files
chore(update-plugins): Sun Sep 17 08:04:57 UTC 2023
1 parent 9b0e938 commit 38e62c0

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

plugins/imagepicker.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ Install the plugin by running the following command in the root directory of you
3939
npm install @nativescript/imagepicker
4040
```
4141

42+
**Note: Version 3.0 contains breaking changes:**
43+
44+
- authorize() now returns a `Promise<AuthorizationResult>` for both android and ios.
45+
- In the returned result from `present()` each `result[i].thumbnail` is now an `ImageSource`.
46+
- `result[i].duration` is now typed correctly as a `number`.
47+
4248
**Note: Version 2.0 contains breaking changes. In order supply more information about your selection, the ImageSource asset is nested in the response so you'll need to update your code to use `result.asset` instead of `result` as your src for your Images.**
4349

4450
## Android required permissions
@@ -114,29 +120,25 @@ let imagePickerObj: ImagePicker = imagePickerPlugin.create({
114120
```ts
115121
imagePickerObj
116122
.authorize()
117-
.then(function () {
118-
return imagePickerObj.present()
119-
})
120-
.then(function (selection) {
121-
selection.forEach(function (selected) {
122-
this.imageSource = selected.asset
123-
this.type = selected.type
124-
this.filesize = selected.filesize
125-
//etc
126-
})
127-
list.items = selection
123+
.then(authResult => {
124+
if (authResult.authorized) {
125+
return imagePickerObj.present().then(function (selection) {
126+
selection.forEach(function (selected) {
127+
this.imageSource = selected.asset
128+
this.type = selected.type
129+
this.filesize = selected.filesize
130+
//etc
131+
})
132+
})
133+
} else {
134+
// process authorization not granted.
135+
}
128136
})
129137
.catch(function (e) {
130138
// process error
131139
})
132140
```
133141

134-
:::tip Note
135-
136-
To request permissions for Android 6+ (API 23+), use [nativescript-permissions](https://www.npmjs.com/package/nativescript-permissions) plugin.
137-
138-
:::
139-
140142
### Demo
141143

142144
You can play with the plugin on StackBlitz at any of the following links:
@@ -152,12 +154,12 @@ You can play with the plugin on StackBlitz at any of the following links:
152154

153155
The class that provides the media selection API. It offers the following methods:
154156

155-
| Method | Returns | Description |
156-
| :----------------------------------------- | :---------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
157-
| `constructor(options: Options)` | `ImagePicker` | Instanciates the ImagePicker class with the optional `options` parameter. See [Options](#options) |
158-
| `authorize()` | `Promise<void>` | Requests the required permissions. Call it before calling `present()`. In case of a failed authorization, consider notifying the user for degraded functionality. |
159-
| `present()` | `Promise<ImageAsset[]>` | Presents the image picker UI. |
160-
| `create(options: Options, hostView: View)` | `ImagePicker` | Creates an instance of the ImagePicker class. The `hostView` parameter can be set to the view that hosts the image picker. Intended to be used when opening the picker from a modal page. |
157+
| Method | Returns | Description |
158+
| :----------------------------------------- | :-------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
159+
| `constructor(options: Options)` | `ImagePicker` | Instanciates the ImagePicker class with the optional `options` parameter. See [Options](#options) |
160+
| `authorize()` | `Promise<AuthorizationResult>` | Requests the required permissions. Call it before calling `present()`. In case of a failed authorization, consider notifying the user for degraded functionality. The returned `AuthorizationResult` will have it's `authorized` property set to `true` if permission has been granted. |
161+
| `present()` | `Promise<ImagePickerSelection[]>` | Presents the image picker UI. |
162+
| `create(options: Options, hostView: View)` | `ImagePicker` | Creates an instance of the ImagePicker class. The `hostView` parameter can be set to the view that hosts the image picker. Intended to be used when opening the picker from a modal page. |
161163

162164
### Options
163165

0 commit comments

Comments
 (0)
0