You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/imagepicker/README.md
+23-15
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,11 @@ Install the plugin by running the following command in the root directory of you
29
29
npm install @nativescript/imagepicker
30
30
```
31
31
32
+
**Note: Version 3.0 contains breaking changes:**
33
+
* authorize() now returns a `Promise<AuthorizationResult>` for both android and ios.
34
+
* In the returned result from `present()` each `result[i].thumbnail` is now an `ImageSource`.
35
+
*`result[i].duration` is now typed correctly as a `number`.
36
+
32
37
**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.**
33
38
34
39
## Android required permissions
@@ -97,22 +102,25 @@ The `present` method resolves with the selected media assets that can you to pro
97
102
```ts
98
103
imagePickerObj
99
104
.authorize()
100
-
.then(function() {
101
-
returnimagePickerObj.present();
102
-
})
103
-
.then(function(selection) {
104
-
selection.forEach(function(selected) {
105
-
this.imageSource=selected.asset;
106
-
this.type=selected.type;
107
-
this.filesize=selected.filesize;
108
-
//etc
109
-
});
110
-
list.items=selection;
111
-
}).catch(function (e) {
105
+
.then((authResult) => {
106
+
if(authResult.authorized) {
107
+
returnimagePickerObj.present()
108
+
.then(function(selection) {
109
+
selection.forEach(function(selected) {
110
+
this.imageSource=selected.asset;
111
+
this.type=selected.type;
112
+
this.filesize=selected.filesize;
113
+
//etc
114
+
});
115
+
});
116
+
} else {
117
+
// process authorization not granted.
118
+
}
119
+
})
120
+
.catch(function (e) {
112
121
// process error
113
122
});
114
123
```
115
-
> **Note** To request permissions for Android 6+ (API 23+), use [nativescript-permissions](https://www.npmjs.com/package/nativescript-permissions) plugin.
116
124
117
125
### Demo
118
126
You can play with the plugin on StackBlitz at any of the following links:
@@ -131,8 +139,8 @@ The class that provides the media selection API. It offers the following methods
131
139
| Method | Returns | Description
132
140
|:-------|:--------|:-----------
133
141
| `constructor(options: Options)` | `ImagePicker` | Instanciates the ImagePicker class with the optional `options` parameter. See [Options](#options)
134
-
| `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.
135
-
| `present()` | `Promise<ImageAsset[]>` | Presents the image picker UI.
142
+
| `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.
143
+
| `present()` | `Promise<ImagePickerSelection[]>` | Presents the image picker UI.
136
144
| `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.
0 commit comments